-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
ribaraka
commented
Aug 23, 2023
- 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
pkg/models/errors.go
Outdated
@@ -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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems better to say:
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea! fixed