From d8d9b8b7c9f2a274d24d8da2d169dd4dc33505d9 Mon Sep 17 00:00:00 2001 From: Dragomir Penev Date: Wed, 24 Apr 2024 22:23:32 +0300 Subject: [PATCH] Don't autostart metrics service if password is not yet set --- src/charm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/charm.py b/src/charm.py index 0008022aa..fe54f2c59 100755 --- a/src/charm.py +++ b/src/charm.py @@ -490,8 +490,7 @@ def reload_pgbouncer(self) -> None: self.check_pgb_running() def _generate_monitoring_service(self, enabled: bool = True) -> Dict[str, str]: - if enabled: - stats_password = self.get_secret(APP_SCOPE, MONITORING_PASSWORD_KEY) + if enabled and (stats_password := self.get_secret(APP_SCOPE, MONITORING_PASSWORD_KEY)): command = ( f'pgbouncer_exporter --web.listen-address=:{METRICS_PORT} --pgBouncer.connectionString="' f'postgres://{self.backend.stats_user}:{stats_password}@localhost:{self.config["listen_port"]}/pgbouncer?sslmode=disable"'