Skip to content

Conversation

marceloneppel
Copy link
Member

@marceloneppel marceloneppel commented Aug 17, 2022

Issue

  • Database charms should enable the human operator to rotate any system user (users that are need for the correct operation of the charm and/or the workload, like a superuser, a replication user, etc.) password.

Solution

  • Create an action to set system users passwords and propagate that password to all the other units.

Context

  • Users created through relations (legacy or new relations) are not covered by this mechanism. Those users will have the password rotated after a sequence of a broken relation and a new relation being established.
  • When updating a password using the 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.
  • Pebble service environment variables like PATRONI_REPLICATION_USERNAME and PATRONI_SUPERUSER_PASSWORD were moved to the configuration file to make it possible to update and reload them. Other variables should be moved to there in the future.
  • The new integration test from 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

  • Unit and integration tests were updated based in the new actions.
  • Additional unit and integration tests were added to validate the password rotation mechanism.

Release Notes

  • Add password rotation mechanism for all system users (users used by the charm/workload and that were not created through relations).

@marceloneppel marceloneppel marked this pull request as ready for review August 25, 2022 18:45
WRFitch
WRFitch previously approved these changes Aug 30, 2022
paulomach
paulomach previously approved these changes Aug 31, 2022
Copy link
Contributor

@paulomach paulomach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

WRFitch
WRFitch previously approved these changes Sep 1, 2022
paulomach
paulomach previously approved these changes Sep 1, 2022
Copy link
Contributor

@paulomach paulomach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm


password = new_password()
if "password" in event.params:
password = event.params["password"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the set_password action has no password params defined

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Fixed on 4be4ed0.

@marceloneppel marceloneppel dismissed stale reviews from paulomach and WRFitch via 4be4ed0 September 1, 2022 18:03
Copy link
Contributor

@paulomach paulomach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@marceloneppel marceloneppel merged commit 5a4aa0f into main Sep 2, 2022
@marceloneppel marceloneppel deleted the password-rotation branch September 2, 2022 10:23
github-actions bot added a commit to canonical/test-runners-2-github-x64-postgresql-k8s-operator that referenced this pull request May 18, 2024
github-actions bot added a commit to canonical/test-runners-2-is-x64-postgresql-k8s-operator that referenced this pull request May 18, 2024
BON4 pushed a commit to BON4/postgresql-k8s-operator that referenced this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants