Add sysinv-dbsync output to log message

This commit adds the stdout+stderr from sysinv-dbsync command
to the error log message if an exception occurs in this step
during 'deploy start' to help troubleshooting sysinv database
migration issues.

Test Plan
PASS: run deploy start successfully
PASS: force failure sysinv-dbsync verify message is logged

Story: 2010676
Task: 51301

Change-Id: I0349515d871948a2a23da57d7a236ad9a5071196
Signed-off-by: Heitor Matsui <heitorvieira.matsui@windriver.com>
This commit is contained in:
Heitor Matsui
2024-11-07 12:26:24 -03:00
parent fe1dbfd270
commit 6cb3454dda

View File

@@ -570,15 +570,14 @@ def migrate_sysinv_database():
sysinv_cmd = 'sysinv-dbsync'
try:
print("Migrating sysinv")
LOG.info("Executing migrate command: %s" % sysinv_cmd)
subprocess.check_call(sysinv_cmd,
shell=True, stdout=sout, stderr=sout)
subprocess.run(sysinv_cmd, shell=True, check=True, text=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as ex:
LOG.exception("Failed to execute command: '%s' during upgrade "
"processing, return code: %d"
% (sysinv_cmd, ex.returncode))
"processing, return code: %d, output: %s"
% (sysinv_cmd, ex.returncode, ex.stdout))
raise