Log db sync failures during retry

Currently there is no log on why the db sync
failed and charm retries the db sync. Add log
on pebble exec error for db sync and reraise
the error.

Change-Id: I103b1b044a7fb55b1fb05bb1e8a461cad3c20c5c
This commit is contained in:
Hemanth Nakkina 2024-05-22 08:52:14 +05:30
parent 0cca8980ef
commit 4081ae07cf
No known key found for this signature in database
GPG Key ID: 2E4970F7B143168E

View File

@ -675,8 +675,12 @@ class OSBaseOperatorCharmK8S(OSBaseOperatorCharm):
def _retry_db_sync(self, cmd):
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, err = process.wait_output()
try:
process = container.exec(cmd, timeout=5 * 60)
out, err = process.wait_output()
except ops.pebble.ExecError as e:
logger.warning(f"DB Sync pebble exec error: {str(e)}")
raise e
if err:
for line in err.splitlines():
logger.warning("DB Sync stderr: %s", line.strip())