-
Notifications
You must be signed in to change notification settings - Fork 1k
Rename roles that are removed from PostgresTeam CRD #1457
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
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.
That is a visible change, so it has to be mentioned at least in the admin docs.
another interesting bur minor question is what happens if someone creates a role that is named exactly like |
} | ||
|
||
// No existing roles are deleted or stripped of role membership/flags | ||
// but team roles will be renamed and denied from LOGIN |
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.
What would happen to roles coming from the Teams API if the API becomes unavailable ?
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 point. I thought, there will be an error and the sync will stop, but no - it continues only with additional members. I return the errors now.
👍 |
I will add an option to enable/disable the feature. |
👍 |
1 similar comment
👍 |
The operator never deletes users (and databases) which where specified once in the cluster manifest or in the PostgresTeams CRD. With the latter it's very easy to add roles to a lot of clusters, but reversing such action manually is cumbersome. We could give some power to the operator to at least rename such "outdated" roles, so that logins with the old username will fail. Deleting the role and corresponding secret might be too dangerous due to depending database objects or deployments.
In this first approach of this PR thereadPgUsersFromDatabase
method is changed to not only retrieve given DB roles, but all roles that can login (or not but have a PW set like roles for preparedDatabases). InProduceSyncRequests
, DB roles that do not exists in thepgUser
map would then trigger a rename request where a suffix is added.Safer: Create a cache for pgUsers and add team roles to name list to pass to
readPgUsersFromDatabase
that do not exist in pgUsers anymore. Lowers the risk of renaming existing DB roles that are not (yet) in the manifest maybe due to cloning/migration etc. However, if the operator pod would crash the users cache is gone and we don't know if roles can be renamed.A new field is added to pgUser struct to mark it for deprecation. The flow is as follows:
New Role
Role is removed
Deprecated
field is still left tofalse
Role is added again
Deprecated
field set totrue
.true
as well. This is fine because this pgUser is not part of dbUsers. It will have no affect in the renaming later.Deprecated
is set totrue
.