-
Notifications
You must be signed in to change notification settings - Fork 27
Password rotation #25
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
Codecov Report
@@ Coverage Diff @@
## main #25 +/- ##
==========================================
+ Coverage 60.11% 61.73% +1.61%
==========================================
Files 6 6
Lines 692 763 +71
Branches 103 118 +15
==========================================
+ Hits 416 471 +55
- Misses 256 264 +8
- Partials 20 28 +8
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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!!
try: | ||
with self._connect_to_database() as connection, connection.cursor() as cursor: | ||
cursor.execute( | ||
sql.SQL("ALTER USER {} WITH ENCRYPTED PASSWORD '" + password + "';").format( |
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.
minor suggestion (feel free to ignore): is it possible to use fstrings instead of .format
?
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.
.format
is needed to correctly escape and handle invalid characters in the user name. But I can improve it to user a Placeholder object from psycopg2 to avoid using the plus signal to concat the password. I will do it in the library in the k8s repository along with other improvements and then update it here.
Thanks for the questions and the suggestion Shayan!
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.
Looks good!
Co-authored-by: Raúl Zamora Martínez <76525382+zmraul@users.noreply.github.com>
* Change charm database user * Fix unit tests * Fix integration test call * Fix user name in library * Fix user * Add default postgres user creation * Change action name * Rework secrets management * Add password rotation logic * Add user to the action parameters * Add pytest marks * Fix action description * Fix method docstring * Fix pytest mark * Update src/charm.py Co-authored-by: Raúl Zamora Martínez <76525382+zmraul@users.noreply.github.com> Co-authored-by: Raúl Zamora Martínez <76525382+zmraul@users.noreply.github.com>
Issue
Solution
Context
set-password
action, that password need to be update in the Patroni configuration (which also needs to be reloaded). The configuration is reloaded in the leader unit first and later on the other units (through relation changed event; that event already handles Patroni configuration changes and its reload process). There is no downtime in that processes.tests/integration/test_password_rotation.py
rotate the two system users password and checks that they are correctly updated in all the units (which is checked after restarting Patroni; it would trigger an connection error in the Patroni process if the password is not updated).Testing
Release Notes