-
Notifications
You must be signed in to change notification settings - Fork 5
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
[MISC] Fix secret keys #212
Conversation
self._translate_field_to_secret_key(AUTH_FILE_DATABAG_KEY), | ||
self._translate_field_to_secret_key(CFG_FILE_DATABAG_KEY), | ||
self._translate_field_to_secret_key(MONITORING_PASSWORD_KEY), |
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.
Needed the transformed peer data keys to properly register as secrets.
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.
Yes, but not just here...
get/set_secret()
functions need to have it translated too, when passing the secret key to the lib.
) | ||
assert secret_uri is not None | ||
assert password is None | ||
assert auth_file is None |
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.
Hopefully avoid the same footgun in the future.
@@ -209,7 +209,6 @@ def _on_changed(self, event: HookEvent): | |||
event.defer() | |||
return | |||
|
|||
self.update_cfg(cfg) |
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.
Caused update secrets restart loop.
tls_enabled = all(self.tls.get_tls_files()) | ||
if self.model.relations.get("certificates", []) and not tls_enabled: | ||
logger.debug( | ||
"pgbouncer_pebble_ready: Deferring as certificates files are not yet populated for existing certificates relation" | ||
) | ||
self.unit.status = WaitingStatus("Waiting for certificates") | ||
event.defer() | ||
return | ||
# in case of pod restart | ||
elif tls_enabled: |
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.
TLS test fails when deferring.
@patch("charm.PostgreSQLTLS.get_tls_files") | ||
@patch("ops.model.Container.make_dir") | ||
def test_on_pgbouncer_pebble_ready_defer_tls(self, _mkdir, get_tls_files): | ||
get_tls_files.return_value = (None, None, None) | ||
|
||
self.harness.add_relation(BACKEND_RELATION_NAME, "postgres") | ||
self.harness.add_relation("certificates", "tls_op") | ||
self.harness.set_leader(True) | ||
# emit on start to ensure config file render | ||
self.charm.on.start.emit() | ||
initial_plan = self.harness.get_container_pebble_plan(PGB) | ||
self.assertEqual(initial_plan.to_yaml(), "{}\n") | ||
|
||
container = self.harness.model.unit.get_container(PGB) | ||
self.charm.on.pgbouncer_pebble_ready.emit(container) | ||
|
||
assert not len(self.harness.model.unit.get_container(PGB).get_services()) | ||
get_tls_files.assert_called_once_with() | ||
self.assertIsInstance(self.harness.model.unit.status, WaitingStatus) | ||
self.assertEqual(self.harness.model.unit.status.message, "Waiting for certificates") | ||
|
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.
No longer deferring in on_pebble_ready
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
self._translate_field_to_secret_key(AUTH_FILE_DATABAG_KEY), | ||
self._translate_field_to_secret_key(CFG_FILE_DATABAG_KEY), | ||
self._translate_field_to_secret_key(MONITORING_PASSWORD_KEY), |
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.
Yes, but not just here...
get/set_secret()
functions need to have it translated too, when passing the secret key to the lib.
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
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!
Peer secrets were set as peer data.