From 419be0f47bcd6b8b2e0eb54b01859a34bb2427fd Mon Sep 17 00:00:00 2001 From: Guillaume Boutry Date: Fri, 23 Feb 2024 11:51:26 +0100 Subject: [PATCH] Always log to debug db_sync's stdout db_sync stdout was logged to debug only when there's output in stderr. Change-Id: I6997d78c32ed6d057a3bea9148c59ed41614205c --- ops-sunbeam/ops_sunbeam/charm.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ops-sunbeam/ops_sunbeam/charm.py b/ops-sunbeam/ops_sunbeam/charm.py index 444a0c72..02b36a1a 100644 --- a/ops-sunbeam/ops_sunbeam/charm.py +++ b/ops-sunbeam/ops_sunbeam/charm.py @@ -680,11 +680,13 @@ class OSBaseOperatorCharmK8S(OSBaseOperatorCharm): container = self.unit.get_container(self.db_sync_container_name) logging.debug("Running sync: \n%s", cmd) process = container.exec(cmd, timeout=5 * 60) - out, warnings = process.wait_output() - if warnings: - for line in warnings.splitlines(): - logger.warning("DB Sync Out: %s", line.strip()) - logging.debug("Output from database sync: \n%s", out) + out, err = process.wait_output() + if err: + for line in err.splitlines(): + logger.warning("DB Sync stderr: %s", line.strip()) + if out: + for line in out.splitlines(): + logger.debug("DB Sync stdout: %s", line.strip()) @sunbeam_job_ctrl.run_once_per_unit("db-sync") def run_db_sync(self) -> None: