fix creating secrets for rotation users #2863
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #2657 a bug was introduced which produces additional secrets for rotation users which are redundant to the original secret. Before syncing secrets we usually initialize the user list to get the desired state.
On UPDATE events we only needed to sync secrets in case the user setup changed.
initUsers
andsyncSecrets
were called in one if block. The behavior was changed to have to if blocks where secrets can be synced on annotations diff while skipping user initializing. Therefore, the current pgUser list is used which contains the rotation users instead of the original ones.We better return to the previous behavior incl. the annotation diff check, even though we would probably always init users then because UPDATEs are usually tiggered from deployments changing the deployment-time annotation.
Another quick hack would be to not generate a secret for rotation users (when
Rotated
flag is true), but since rotation users replace their original counterparts in the pgUsers list, we would then not sync the corresponding secrets.In a first step I extended the e2e test without changing any other code (quick hack only as a comment) to reproduce the bug.