-
Notifications
You must be signed in to change notification settings - Fork 509
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
CLOUDP-196371: Delete users removed from the resource #1587
CLOUDP-196371: Delete users removed from the resource #1587
Conversation
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.
Thanks for your changes! They are looking good! Just some suggestions here and there
test/e2e/replica_set_remove_user/replica_set_remove_user_test.go
Outdated
Show resolved
Hide resolved
test/e2e/replica_set_remove_user/replica_set_remove_user_test.go
Outdated
Show resolved
Hide resolved
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.
Thanks for your contribution, LGTM! One small cleanup and we should be good to go once all tests are green
Summary:
This PR adds changes that will cleanup connection string secrets after a user is removed from the resource and ensure that it will also be removed from the database.
Connection string secrets are removed by comparing the
lastAppliedSpec
with the current spec to retrieve the users that have been removed and then their corresponding connection string secrets.Users are deleted from the database by adding a corresponding
DeletedUser
object to theusersDeleted
field in theauth
object of theAutomationConfig
. This ensures the users will be deleted according to the documentationThe PR adds:
controllers/mongodb_cleanup.go
file:getConnectionStringSecretsToDelete
that compares the previous spec with the current one and returns a slice containing the secrets corresponding to removed userscleanupConnectionStringSecrets
that deletes the secrets returned by the previous methodlastAppliedSpec
parameter tor.deployMongoDBReplicaSet
,r.deployAutomationConfig
,r.ensureAutomationConfig
,r.buildAutomationConfig
to allow it to be used to retrieve removed userspkg/authentication/authentication.go
file:getDeletedUsers
that usseslastAppliedSpec
to return a slice ofDeletedUser
s corresponding to the removed users from the specAddRemovedUsers
that adds the users returned by the previous method to theusersDeleted
field in theauth
UsersDeleted
field to theAuth
type. This contains of a slice of objects of typeDeletedUser
, which contain 2 fields:User
: The user that will be deletedDbs
: A list of databses from which the user should be deletedtest/e2e/mongodbtests/mongodbtests.go
file:RemoveUserFromResource
that sets theusers
field in the spec of the resource to an empty listConnectionStringSecretsAreCleanedUp
that checks that a specific connection string secret is not found in the cluster anymoreAuthUsersDeletedIsUpdated
that checks that theauth
was updated to contain the specified userauth
to be updatedAll Submissions:
closes #XXXX
in your comment to auto-close the issue that your PR fixes (if such).