ostree-installer: Clean up output dir

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-06-15 08:10:56 +02:00
parent 1c3637c48f
commit 6e6e250cec
2 changed files with 6 additions and 3 deletions

View File

@ -127,7 +127,7 @@ class OstreeInstallerThread(WorkerThread):
def _run_ostree_cmd(self, compose, variant, arch, config, source_repo, output_dir, volid): def _run_ostree_cmd(self, compose, variant, arch, config, source_repo, output_dir, volid):
lorax_wrapper = lorax.LoraxWrapper() lorax_wrapper = lorax.LoraxWrapper()
cmd = lorax_wrapper.get_lorax_cmd( lorax_cmd = lorax_wrapper.get_lorax_cmd(
compose.conf['release_name'], compose.conf['release_name'],
compose.conf["release_version"], compose.conf["release_version"],
self._get_release(compose, config), self._get_release(compose, config),
@ -145,6 +145,8 @@ class OstreeInstallerThread(WorkerThread):
is_final=compose.supported, is_final=compose.supported,
log_dir=self.logdir, 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_channel = compose.conf.get("runroot_channel")
runroot_tag = compose.conf["runroot_tag"] runroot_tag = compose.conf["runroot_tag"]

View File

@ -97,11 +97,12 @@ class OstreeThreadTest(helpers.PungiTestCase):
if extra: if extra:
lorax_cmd.extend(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, self.assertEqual(koji.get_runroot_cmd.call_args_list,
[mock.call('rrt', 'x86_64', [mock.call('rrt', 'x86_64',
lorax_cmd, 'rm -rf %s && %s' % (outdir, ' '.join(lorax_cmd)),
channel=None, mounts=[self.topdir], channel=None, mounts=[self.topdir],
packages=['pungi', 'lorax', 'ostree'], packages=['pungi', 'lorax', 'ostree'],
task_id=True, use_shell=True, weight=weight)]) task_id=True, use_shell=True, weight=weight)])