runroot: Remove useless argument output_path

The same logic is handled by `chown_paths`, which does the same thing
but supports multiple paths.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-05-22 12:54:26 +02:00
parent 1951b0a521
commit 551f52922f
5 changed files with 22 additions and 25 deletions

View File

@ -422,7 +422,7 @@ class BuildinstallThread(WorkerThread):
# Get list of packages which are neded in runroot. # Get list of packages which are neded in runroot.
packages = [] packages = []
chown_paths = [] chown_paths = [output_dir]
if buildinstall_method == "lorax": if buildinstall_method == "lorax":
packages += ["lorax"] packages += ["lorax"]
chown_paths.append(_get_log_dir(compose, variant, arch)) chown_paths.append(_get_log_dir(compose, variant, arch))
@ -438,7 +438,7 @@ class BuildinstallThread(WorkerThread):
runroot = Runroot(compose) runroot = Runroot(compose)
runroot.run( runroot.run(
cmd, log_file=log_file, arch=arch, packages=packages, cmd, log_file=log_file, arch=arch, packages=packages,
mounts=[compose.topdir], output_dir=output_dir, mounts=[compose.topdir],
weight=compose.conf['runroot_weights'].get('buildinstall'), weight=compose.conf['runroot_weights'].get('buildinstall'),
chown_paths=chown_paths, chown_paths=chown_paths,
) )

View File

@ -187,5 +187,5 @@ class OstreeInstallerThread(WorkerThread):
runroot = Runroot(compose) runroot = Runroot(compose)
runroot.run( runroot.run(
cmd, log_file=log_file, arch=arch, packages=packages, cmd, log_file=log_file, arch=arch, packages=packages,
mounts=[compose.topdir], output_dir=output_dir, mounts=[compose.topdir], chown_paths=[output_dir],
weight=compose.conf['runroot_weights'].get('ostree_installer')) weight=compose.conf['runroot_weights'].get('ostree_installer'))

View File

@ -59,17 +59,13 @@ class Runroot(kobo.log.LoggingBase):
run(command, show_cmd=True, logfile=log_file) run(command, show_cmd=True, logfile=log_file)
self._result = True self._result = True
def _run_koji(self, command, log_file=None, packages=None, def _run_koji(self, command, log_file=None, packages=None, arch=None, **kwargs):
arch=None, output_dir=None, **kwargs):
""" """
Runs the runroot command in Koji. Runs the runroot command in Koji.
""" """
runroot_channel = self.compose.conf.get("runroot_channel") runroot_channel = self.compose.conf.get("runroot_channel")
runroot_tag = self.compose.conf["runroot_tag"] runroot_tag = self.compose.conf["runroot_tag"]
if output_dir:
kwargs.setdefault("chown_paths", []).append(output_dir)
koji_wrapper = kojiwrapper.KojiWrapper(self.compose.conf["koji_profile"]) koji_wrapper = kojiwrapper.KojiWrapper(self.compose.conf["koji_profile"])
koji_cmd = koji_wrapper.get_runroot_cmd( koji_cmd = koji_wrapper.get_runroot_cmd(
runroot_tag, arch, command, runroot_tag, arch, command,
@ -102,7 +98,7 @@ class Runroot(kobo.log.LoggingBase):
return run(ssh_cmd, show_cmd=True, logfile=log_file)[1] return run(ssh_cmd, show_cmd=True, logfile=log_file)[1]
def _run_openssh(self, command, log_file=None, arch=None, packages=None, def _run_openssh(self, command, log_file=None, arch=None, packages=None,
output_dir=None, **kwargs): chown_paths=None, **kwargs):
""" """
Runs the runroot command on remote machine using ssh. Runs the runroot command on remote machine using ssh.
""" """
@ -112,11 +108,12 @@ class Runroot(kobo.log.LoggingBase):
# If the output dir is defined, change the permissions of files generated # If the output dir is defined, change the permissions of files generated
# by the runroot task, so the Pungi user can access them. # by the runroot task, so the Pungi user can access them.
if output_dir: if chown_paths:
paths = " ".join(shlex_quote(pth) for pth in chown_paths)
# Make the files world readable # Make the files world readable
command += " && chmod -R a+r %s" % shlex_quote(output_dir) command += " && chmod -R a+r %s" % paths
# and owned by the same user that is running the process # and owned by the same user that is running the process
command += " && chown -R %d %s" % (os.getuid(), shlex_quote(output_dir)) command += " && chown -R %d %s" % (os.getuid(), paths)
hostname = runroot_ssh_hostnames[arch] hostname = runroot_ssh_hostnames[arch]
user = self.compose.conf.get("runroot_ssh_username", "root") user = self.compose.conf.get("runroot_ssh_username", "root")
@ -172,8 +169,7 @@ class Runroot(kobo.log.LoggingBase):
continue continue
self._result.append(i) self._result.append(i)
def run(self, command, log_file=None, packages=None, arch=None, def run(self, command, log_file=None, packages=None, arch=None, **kwargs):
output_dir=None, **kwargs):
""" """
Runs the runroot task using the `Runroot.runroot_method`. Blocks until Runs the runroot task using the `Runroot.runroot_method`. Blocks until
the runroot task is successfully finished. Raises an exception on error. the runroot task is successfully finished. Raises an exception on error.
@ -196,16 +192,16 @@ class Runroot(kobo.log.LoggingBase):
""" """
if self.runroot_method == "local": if self.runroot_method == "local":
self._run_local( self._run_local(
command, log_file=log_file, packages=packages, arch=arch, command, log_file=log_file, packages=packages, arch=arch, **kwargs
output_dir=output_dir, **kwargs) )
elif self.runroot_method == "koji": elif self.runroot_method == "koji":
self._run_koji( self._run_koji(
command, log_file=log_file, packages=packages, arch=arch, command, log_file=log_file, packages=packages, arch=arch, **kwargs
output_dir=output_dir, **kwargs) )
elif self.runroot_method == "openssh": elif self.runroot_method == "openssh":
self._run_openssh( self._run_openssh(
command, log_file=log_file, packages=packages, arch=arch, command, log_file=log_file, packages=packages, arch=arch, **kwargs
output_dir=output_dir, **kwargs) )
else: else:
raise ValueError("Unknown runroot_method %r." % self.runroot_method) raise ValueError("Unknown runroot_method %r." % self.runroot_method)

View File

@ -605,8 +605,8 @@ class BuildinstallThreadTestCase(PungiTestCase):
use_shell=True, task_id=True, use_shell=True, task_id=True,
packages=['lorax'], mounts=[self.topdir], weight=123, packages=['lorax'], mounts=[self.topdir], weight=123,
chown_paths=[ chown_paths=[
os.path.join(self.topdir, "logs/x86_64/buildinstall-Server-logs"),
destdir, destdir,
os.path.join(self.topdir, "logs/x86_64/buildinstall-Server-logs"),
], ],
)]) )])
self.assertItemsEqual( self.assertItemsEqual(
@ -849,8 +849,8 @@ class BuildinstallThreadTestCase(PungiTestCase):
use_shell=True, task_id=True, use_shell=True, task_id=True,
packages=['lorax'], mounts=[self.topdir], weight=123, packages=['lorax'], mounts=[self.topdir], weight=123,
chown_paths=[ chown_paths=[
"/buildinstall_topdir/buildinstall-%s/x86_64/Server/logs" % os.path.basename(self.topdir),
"/buildinstall_topdir/buildinstall-%s/x86_64/Server" % os.path.basename(self.topdir), "/buildinstall_topdir/buildinstall-%s/x86_64/Server" % os.path.basename(self.topdir),
"/buildinstall_topdir/buildinstall-%s/x86_64/Server/logs" % os.path.basename(self.topdir),
], ],
)]) )])
self.assertItemsEqual( self.assertItemsEqual(

View File

@ -121,10 +121,11 @@ class TestRunrootOpenSSH(helpers.PungiTestCase):
run.return_value = (0, "key\n") run.return_value = (0, "key\n")
self.runroot.run("df -h", log_file="/foo/runroot.log", arch="x86_64", self.runroot.run("df -h", log_file="/foo/runroot.log", arch="x86_64",
packages=["lorax", "automake"], output_dir="/mnt/foo/compose") packages=["lorax", "automake"],
chown_paths=["/mnt/foo/compose", "/mnt/foo/x"])
run.assert_has_calls([ run.assert_has_calls([
self._ssh_call( self._ssh_call(
'run df -h && chmod -R a+r /mnt/foo/compose && ' "run df -h && chmod -R a+r /mnt/foo/compose /mnt/foo/x && "
'chown -R %d /mnt/foo/compose' % os.getuid()), "chown -R %d /mnt/foo/compose /mnt/foo/x" % os.getuid()),
self._ssh_call("run rpm -qa --qf='%{name}-%{version}-%{release}.%{arch}\n'"), self._ssh_call("run rpm -qa --qf='%{name}-%{version}-%{release}.%{arch}\n'"),
]) ])