From 6e6e250cec8d0fa12c3e2ded9b028fb335380dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 15 Jun 2017 08:10:56 +0200 Subject: [PATCH] ostree-installer: Clean up output dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Koji task can be restarted and lorax will fail if the output directory already exists. Let's start the work in runroot by removing the output directory. Relates: #641 Signed-off-by: Lubomír Sedlář --- pungi/phases/ostree_installer.py | 4 +++- tests/test_ostree_installer_phase.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pungi/phases/ostree_installer.py b/pungi/phases/ostree_installer.py index 895827e1..e6f43bbd 100644 --- a/pungi/phases/ostree_installer.py +++ b/pungi/phases/ostree_installer.py @@ -127,7 +127,7 @@ class OstreeInstallerThread(WorkerThread): def _run_ostree_cmd(self, compose, variant, arch, config, source_repo, output_dir, volid): lorax_wrapper = lorax.LoraxWrapper() - cmd = lorax_wrapper.get_lorax_cmd( + lorax_cmd = lorax_wrapper.get_lorax_cmd( compose.conf['release_name'], compose.conf["release_version"], self._get_release(compose, config), @@ -145,6 +145,8 @@ class OstreeInstallerThread(WorkerThread): is_final=compose.supported, log_dir=self.logdir, ) + cmd = 'rm -rf %s && %s' % (pipes.quote(output_dir), + ' '.join([pipes.quote(x) for x in lorax_cmd])) runroot_channel = compose.conf.get("runroot_channel") runroot_tag = compose.conf["runroot_tag"] diff --git a/tests/test_ostree_installer_phase.py b/tests/test_ostree_installer_phase.py index b0daeeed..ba56d8c7 100644 --- a/tests/test_ostree_installer_phase.py +++ b/tests/test_ostree_installer_phase.py @@ -97,11 +97,12 @@ class OstreeThreadTest(helpers.PungiTestCase): if extra: lorax_cmd.extend(extra) - lorax_cmd.append(self.topdir + '/work/x86_64/Everything/ostree_installer') + outdir = self.topdir + '/work/x86_64/Everything/ostree_installer' + lorax_cmd.append(outdir) self.assertEqual(koji.get_runroot_cmd.call_args_list, [mock.call('rrt', 'x86_64', - lorax_cmd, + 'rm -rf %s && %s' % (outdir, ' '.join(lorax_cmd)), channel=None, mounts=[self.topdir], packages=['pungi', 'lorax', 'ostree'], task_id=True, use_shell=True, weight=weight)])