Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASTRACTL-32772: rework Trident upgrade logic, better error handling #352

Merged
merged 26 commits into from
Jun 5, 2024

Conversation

palicena
Copy link
Collaborator

@palicena palicena commented Jun 4, 2024

  • Reworked and simplified Trident upgrade logic
  • Added better error handling for all kubectl get commands; we'll now be able to differentiate connection/timeout errors VS not found, and users will get much better feedback when something does go wrong

@palicena palicena changed the base branch from main to ASTRACTL-32772-misc-fixes-6 June 4, 2024 19:31
@@ -1097,10 +1097,9 @@ get_registry_credentials_from_pull_secret() {
# 6. Get the first matching entry's `.value.auth`, which would be `B64_ENCODED_USERNAME_PASSWORD` here
# 7. The `B64_ENCODED_USERNAME_PASSWORD` can then be passed to curl via
# `-H 'Authorization: Basic B64_ENCODED_USERNAME_PASSWORD'` without having to decode it first.
local -r contents="$(kubectl get secret "$pull_secret" -n "$namespace" -o json 2> /dev/null)"
local -r contents="$(k8s_get_resource "secret/$pull_secret" "$namespace" "json")"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll see quite a few of these changes; most kubectl get commands now instead use k8s_get_resource or k8s_resource_exists, which actually handles kubectl errors instead of just sending them into the void.

if [ -z "$current" ] || [ "$current" == null ] || [ -n "$captured_err" ]; then
add_problem "Failed to get your cluster's Kubernetes version: $captured_err"
return 1
fi
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is not a kubectl get and is only called once, the error is handled here instead of using k8s_get_resource or k8s_resource_exists (or making a new function).

else
add_problem "k8s permissions: user does not have admin privileges" "Kubernetes user does not have admin privileges"
add_problem "Failed to check if Kubernetes user has admin privilege: unknown error"
Copy link
Collaborator Author

@palicena palicena Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, this kubectl auth can-i is pretty unique and not called anywhere else so we just handle the errors in-line instead of making a new function.

@@ -2350,6 +2416,7 @@ step_apply_resources() {
# Apply operator resources
logdebug "apply operator resources"
local output=""
local captured_err=""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable declaration was missing, so the call 3 lines down was putting the value in a global variable instead.

Base automatically changed from ASTRACTL-32772-misc-fixes-6 to main June 4, 2024 21:55
@palicena palicena marked this pull request as ready for review June 5, 2024 14:16
palicena and others added 3 commits June 5, 2024 14:43
* Revert "ASTRACTL-32772: remove pull secret stuff"

This reverts commit 8af69b1.

* ASTRACTL-32772: better pull secret handling

* ASTRACTL-32772: rework registry resolution for error message

* ASTRACTL-32772: suppress unneeded registry output
…-connector-operator into ASTRACTL-32772-misc-fixes-7
Copy link

github-actions bot commented Jun 5, 2024

Code Coverage

Package Line Rate
github.com/NetApp-Polaris/astra-connector-operator/app/conf 75%
github.com/NetApp-Polaris/astra-connector-operator/app/deployer/connector 91%
github.com/NetApp-Polaris/astra-connector-operator/app/deployer 100%
github.com/NetApp-Polaris/astra-connector-operator/app/deployer/model 100%
github.com/NetApp-Polaris/astra-connector-operator/app/deployer/neptune 85%
github.com/NetApp-Polaris/astra-connector-operator/app/register 16%
github.com/NetApp-Polaris/astra-connector-operator/details/k8s 62%
github.com/NetApp-Polaris/astra-connector-operator/details/k8s/precheck 56%
github.com/NetApp-Polaris/astra-connector-operator/details/operator-sdk/api/v1 46%
github.com/NetApp-Polaris/astra-connector-operator/details/operator-sdk/controllers 0%
github.com/NetApp-Polaris/astra-connector-operator/util 100%
Summary 55% (950 / 1742)

Minimum allowed line rate is 50%

@palicena palicena merged commit 380dc9f into main Jun 5, 2024
3 checks passed
@palicena palicena deleted the ASTRACTL-32772-misc-fixes-7 branch June 5, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants