-
Notifications
You must be signed in to change notification settings - Fork 363
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
fix(rds)!: Rework handling of masterPasswordSecretRef #1756
Merged
MisterMX
merged 1 commit into
crossplane-contrib:master
from
schroeder-paul:feat/dbs/change-master-password-1571
Jul 28, 2023
Merged
fix(rds)!: Rework handling of masterPasswordSecretRef #1756
MisterMX
merged 1 commit into
crossplane-contrib:master
from
schroeder-paul:feat/dbs/change-master-password-1571
Jul 28, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MisterMX
requested changes
May 25, 2023
d7a3a79
to
9c83b2b
Compare
MisterMX
approved these changes
Jun 1, 2023
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.
LGTM. Thanks @schroeder-paul.
@chlunde, @haarchri since this is quite a complicated PR, can you take a second or third look at it?
9c83b2b
to
a7eaa8a
Compare
2fa4a21
to
fc02a61
Compare
fc02a61
to
ab4a5c4
Compare
Signed-off-by: Paul Schroeder (external expert on behalf of DB Netz) <paul.schroeder-extern@deutschebahn.com> Signed-off-by: Maximilian Blatt (external expert on behalf of DB Netz) <maximilian.blatt-extern@deutschebahn.com> Co-authored-by: Maximilian Blatt (external expert on behalf of DB Netz) <maximilian.blatt-extern@deutschebahn.com>
ab4a5c4
to
d61ae02
Compare
Rebased on latest master. LGTM. Thanks a lot @schroeder-paul! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of your changes
Problems
masterPasswordSecretRef
is absolutely necessary for both resources (dbcluster, dbinstance) to be claimed. This is since the referenced secret is used as a cache for autogenerated secrets (or for the actual secret). So an input parameter (the secret) is used for internal purposes and might be rewritten.Remedy (proposal)
preCreate
source (sample from instance):crossplane-namespace
. With the name combined from the resource kind and its UID:<resource kind | tolower>.<uid>
. It holds the cached secret and info about the restore state.rds/common.go
got more functions and an interfaceRDSClusterOrInstance
was introduced to make it possible for these functions to handle both resource types (instance and cluster).The changes are quite a mouth full, but I am sure they will improve the workflow and add value. Please have a close review.
Fixes: #1571
I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested
dbinstance - autogeneratePassword: true - masterUserPasswordSecretRef: null - writeConnectionSecretToRef: null
$ k view-secret -n crossplane-system dbinstance.$(kg dbinstance.rds.aws example-dbinstance -oyaml | yq .metadata.uid) Choosing key: dbMasterUserPassword Lp9goLGeTT21eKvUeKhutGHNxWA
dbinstance - autogeneratePassword: true - masterUserPasswordSecretRef: null - writeConnectionSecretToRef: set
$ k view-secret -n crossplane-system dbinstance.$(kg dbinstance.rds.aws example-dbinstance -oyaml | yq .metadata.uid) Choosing key: dbMasterUserPassword Lp9goLGeTT21eKvUeKhutGHNxWA
NOTE: The two passwords do match!
dbinstance - autogeneratePassword: true - masterUserPasswordSecretRef: set/changed - writeConnectionSecretToRef: set
$ k view-secret -n crossplane-system dbinstance.$(kg dbinstance.rds.aws example-dbinstance -oyaml | yq .metadata.uid) Choosing key: dbMasterUserPassword foobar123
NOTE: Passwords coincide and are not autogenerated
$ k view-secret -n crossplane-system dbinstance.$(kg dbinstance.rds.aws example-dbinstance -oyaml | yq .metadata.uid) --all dbMasterUserPassword=123barfoo dbWasRestored=
Password change worked!
dbinstance (restore) - autogeneratePassword: null - masterUserPasswordSecretRef: null/set - writeConnectionSecretToRef: set
Now the OLD password can be used:
To connect to the DB:
Or it can be changed:
dbcluster - autogeneratePassword: true - masterUserPasswordSecretRef: null - writeConnectionSecretToRef: set
Note if no port was given, the default is used but 0 is displayed (the cluster observation does not supply it). The behaviour will be changed to not display the port if it is the default (to also adher more to the instance).
dbcluster - autogeneratePassword: true - masterUserPasswordSecretRef: set/changed - writeConnectionSecretToRef: set
dbcluster (restore) - autogeneratePassword: null - masterUserPasswordSecretRef: null/set - writeConnectionSecretToRef: set
Old DB:
New (restored DB):
Set new password: