Remove passt when virt-customize does not work

When tobiko runs virt-customize on a podified environment, the command
fails because passt cannot be used.
This patch adds a temporary workaround until the issue is fixed.

TOBIKO-122

Change-Id: I7b52387d1ad889da2f4b77cb05cd5af457d83e89
This commit is contained in:
Eduardo Olivares 2024-10-28 16:42:28 +01:00
parent f33c1d8def
commit 89e278381f

View File

@ -444,6 +444,21 @@ class CustomizedGlanceImageFixture(FileGlanceImageFixture):
return 'customized'
def customize_image_file(self, base_file: str) -> str:
def workaround_passt(full_command, exc):
which_passt = sh.execute(
'which passt', expect_exit_status=None).stdout.rstrip()
if which_passt == '':
raise exc
cmd = f'mv {which_passt} {which_passt}.bak'
cmd_cleanup = f'mv {which_passt}.bak {which_passt}'
tobiko.add_cleanup(sh.execute, cmd_cleanup,
expect_exit_status=None, sudo=True)
LOG.exception("Executing virt-customize without passt")
sh.execute(cmd, sudo=True)
sh.execute(full_command)
customized_file = f'{base_file}-{self._get_customized_suffix()}'
if os.path.isfile(customized_file):
if (os.stat(base_file).st_mtime_ns <
@ -464,7 +479,10 @@ class CustomizedGlanceImageFixture(FileGlanceImageFixture):
'virt-customize',
'-a',
work_file])
sh.execute(command + options)
try:
sh.execute(command + options)
except sh.ShellCommandFailed as exc:
workaround_passt(command + options, exc)
sh.get_file(work_file, customized_file)
return customized_file