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
This commit is contained in:
Guillaume Boutry 2024-02-23 11:51:26 +01:00
parent 98f2a29cc2
commit 419be0f47b
No known key found for this signature in database
GPG Key ID: E95E3326872E55DE

View File

@ -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: