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

issue-469, delete all users from deleted cluster #481

Merged
merged 1 commit into from
Jul 21, 2023

Conversation

OleksiienkoMykyta
Copy link
Collaborator

No description provided.

@OleksiienkoMykyta OleksiienkoMykyta force-pushed the issue-469-delete-all-users-from-deleted-cluster branch 2 times, most recently from 2b057d8 to 2ec620f Compare July 18, 2023 14:08
@OleksiienkoMykyta OleksiienkoMykyta requested review from ribaraka, testisnullus and worryg0d and removed request for ribaraka July 18, 2023 14:09
@OleksiienkoMykyta OleksiienkoMykyta force-pushed the issue-469-delete-all-users-from-deleted-cluster branch from 2ec620f to 7c3c9eb Compare July 19, 2023 09:08
@OleksiienkoMykyta OleksiienkoMykyta changed the title [WIP]issue-469-delete-all-users-from-deleted-cluster issue-469, delete all users from deleted cluster Jul 19, 2023
@OleksiienkoMykyta OleksiienkoMykyta force-pushed the issue-469-delete-all-users-from-deleted-cluster branch 2 times, most recently from f614e6b to 6729b4f Compare July 19, 2023 09:27
@OleksiienkoMykyta OleksiienkoMykyta force-pushed the issue-469-delete-all-users-from-deleted-cluster branch 2 times, most recently from 58cb36a to 8861645 Compare July 19, 2023 10:02
Comment on lines 217 to 223
err = r.detachUserFromDeletedCluster(ctx, clusterID, user, l)
if err != nil {
l.Error(err, "Cannot delete Redis user resource",
"secret name", secret.Name,
"secret namespace", secret.Namespace)
r.EventRecorder.Eventf(user, models.Warning, models.PatchFailed,
"Resource deleting is failed. Reason: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. it's not a patch operation
  2. typos in the logs. deleting -> detach

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

return err
}

patch = user.NewPatch()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to reinitialize a patch

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

for _, ref := range redis.Spec.UserRefs {
err = r.detachUserResource(ctx, logger, redis, ref)
if err != nil {
logger.Error(err, "Cannot delete Redis user cluster",
Copy link
Contributor

Choose a reason for hiding this comment

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

delete -> detach

Copy link
Collaborator Author

@OleksiienkoMykyta OleksiienkoMykyta Jul 20, 2023

Choose a reason for hiding this comment

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

Fixed

@OleksiienkoMykyta OleksiienkoMykyta force-pushed the issue-469-delete-all-users-from-deleted-cluster branch from 8861645 to 3dd3402 Compare July 19, 2023 14:49
"secret name", secret.Name,
"secret namespace", secret.Namespace)
r.EventRecorder.Eventf(user, models.Warning, models.UpdatedEvent,
"Cannot assign Cassandra user to a k8s secret. Reason: %v", err)
"Cannot assign Redis user to a k8s secret. Reason: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cannot assign k8s secret to a Redis user maybe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you are right, thank you!
Fixed

@@ -174,9 +174,9 @@ func (r *RedisUserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
userID := fmt.Sprintf(instaclustr.RedisUserIDFmt, clusterID, user.Namespace)
err = r.API.DeleteRedisUser(userID)
if err != nil {
l.Error(err, "Cannot delete Redis user", "user", user.Name)
l.Error(err, "Cannot delete Redis user on Instaclustr", "user", user.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does Cannot delete Redis user on Instaclustr mean? We delete users from a cluster, isn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, fixed

return err
}

controllerutil.RemoveFinalizer(user, user.DeletionUserFinalizer(clusterID, user.Namespace))
Copy link
Collaborator

Choose a reason for hiding this comment

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

DeletionUserFinalizer -> DeletionFinalizer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a separate method for user, DeletionFinalizer used for secrets

for _, ref := range redis.Spec.UserRefs {
err = r.detachUserResource(ctx, logger, redis, ref)
if err != nil {
logger.Error(err, "Cannot detach Redis user cluster",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cannot detach Redis user cluster -> Cannot detach Redis user

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@OleksiienkoMykyta OleksiienkoMykyta force-pushed the issue-469-delete-all-users-from-deleted-cluster branch from 3dd3402 to 9430e84 Compare July 20, 2023 13:35
@@ -174,9 +174,9 @@ func (r *RedisUserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
userID := fmt.Sprintf(instaclustr.RedisUserIDFmt, clusterID, user.Namespace)
err = r.API.DeleteRedisUser(userID)
if err != nil {
l.Error(err, "Cannot delete Redis user", "user", user.Name)
l.Error(err, "Cannot delete Redis user on cluster. Cluster ID: %s.", "user", clusterID, user.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cannot delete Redis user on cluster -> Cannot delete Redis user from the cluster

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed


l.Error(err, "Cannot get Redis user", "user", u.Spec)
r.EventRecorder.Eventf(redis, models.Warning, models.DeletionFailed,
"Cannot get Redis user. user reference: %v", uRef)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cannot get Redis user. user reference -> Cannot get Redis user. User reference

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@OleksiienkoMykyta OleksiienkoMykyta force-pushed the issue-469-delete-all-users-from-deleted-cluster branch from 9430e84 to 53cbdd7 Compare July 20, 2023 14:39
@testisnullus testisnullus added the enhancement New feature or request label Jul 20, 2023
@taaraora taaraora merged commit 2d7972e into main Jul 21, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants