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

Fixes for the User CRDs #533

Merged
merged 1 commit into from
Aug 28, 2023
Merged

Fixes for the User CRDs #533

merged 1 commit into from
Aug 28, 2023

Conversation

ribaraka
Copy link
Contributor

  • removed redundant finalizers in user functionality, which is set after each new cluster assignment.
  • from now on we will use only one and only finalizer that is bound between a User CRD and the Secret.
  • added a const containing a message for user deletion
  • cleaned up a code
  • moved the adding finalizers at the beginning of the reconcile func
  • fixes along the way for some user controllers.
  • Closes [User CRD] New finilizer to a deleting resource #532

@ribaraka ribaraka added bug Something isn't working refactor Code improvements or refactorings labels Aug 23, 2023
@ribaraka ribaraka self-assigned this Aug 23, 2023
@@ -54,6 +54,6 @@ var (
ErrImmutableSecretRef = errors.New("secret reference is immutable")
ErrEmptySecretRef = errors.New("secretRef.name and secretRef.namespace should not be empty")
ErrMissingSecretKeys = errors.New("the secret is missing the correct keys for the user")
ErrUserStillExist = errors.New("the user is still attached to cluster")
ErrUserStillExist = errors.New("the user is still attached to cluster. If you want to delete the user, first remove the user from cluster specification")
Copy link
Collaborator

Choose a reason for hiding this comment

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

user is still attached to cluster. If you want to delete the user, first remove the user from cluster specification -> the user is still attached to the cluster. If you want to delete the user, remove the user from the cluster specification first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

func getDeletionUserFinalizer(clusterID string) string {
return models.DeletionUserFinalizer + clusterID
}
const msgDeleteUser = "If you want to delete the user, first remove the user from cluster specification"
Copy link
Collaborator

@worryg0d worryg0d Aug 23, 2023

Choose a reason for hiding this comment

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

Seems better to say:

Suggested change
const msgDeleteUser = "If you want to delete the user, first remove the user from cluster specification"
const msgDeleteUser = "If you want to delete the user, remove it from the clusters specifications first"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

Comment on lines 417 to 348
l.Error(models.ErrUserStillExist, "please remove the user from the cluster specification",
l.Error(models.ErrUserStillExist, "If you want to delete the user, first remove the user from cluster specification",
"username", username, "cluster ID", clusterID)
r.EventRecorder.Event(user, models.Warning, models.DeletingEvent,
"The user is still attached to cluster, please remove the user from the cluster specification.")
"If you want to delete the user, first remove the user from cluster specification")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use here msgDeleteUser as you do in other similar cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


return models.ReconcileRequeue, nil
}

if controllerutil.AddFinalizer(secret, user.GetDeletionFinalizer()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to add finalizer after getting creds

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea! fixed

@taaraora taaraora merged commit 3c1de94 into main Aug 28, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor Code improvements or refactorings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[User CRD] New finilizer to a deleting resource
6 participants