buildinstall: Fix treeinfo generating on failure

When buildinstall fails, there will be no lorax generated files copied
into the compose directory. However they may still be mentioned in the
.treefile in work/ subdirectory where lorax runs.

To avoid possible issues, we should use the lorax created .treeinfo only
if the run was successful.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-11-08 14:24:01 +01:00
parent 930c2f1a42
commit 61a3be2307
3 changed files with 14 additions and 13 deletions

View File

@ -397,7 +397,7 @@ def run_compose(compose, create_latest_link=True, latest_link_status=None):
# write treeinfo before ISOs are created # write treeinfo before ISOs are created
for variant in compose.get_variants(): for variant in compose.get_variants():
for arch in variant.arches + ["src"]: for arch in variant.arches + ["src"]:
pungi.metadata.write_tree_info(compose, arch, variant) pungi.metadata.write_tree_info(compose, arch, variant, bi=buildinstall_phase)
# write .discinfo and media.repo before ISOs are created # write .discinfo and media.repo before ISOs are created
for variant in compose.get_variants(): for variant in compose.get_variants():

View File

@ -185,7 +185,7 @@ def write_compose_info(compose):
compose.log_info("[DONE ] %s" % msg) compose.log_info("[DONE ] %s" % msg)
def write_tree_info(compose, arch, variant, timestamp=None): def write_tree_info(compose, arch, variant, timestamp=None, bi=None):
if variant.type in ("addon", ) or variant.is_empty: if variant.type in ("addon", ) or variant.is_empty:
return return
@ -288,7 +288,7 @@ def write_tree_info(compose, arch, variant, timestamp=None):
self.release = LoraxProduct(self) self.release = LoraxProduct(self)
# images # images
if variant.type == "variant": if variant.type == "variant" and bi.succeeded(variant, arch):
os_tree = compose.paths.compose.os_tree(arch, variant) os_tree = compose.paths.compose.os_tree(arch, variant)
# clone all but 'general' sections from buildinstall .treeinfo # clone all but 'general' sections from buildinstall .treeinfo

View File

@ -45,6 +45,8 @@ class BuildinstallPhase(PhaseBase):
# A set of (variant_uid, arch) pairs that completed successfully. This # A set of (variant_uid, arch) pairs that completed successfully. This
# is needed to skip copying files for failed tasks. # is needed to skip copying files for failed tasks.
self.pool.finished_tasks = set() self.pool.finished_tasks = set()
self.buildinstall_method = self.compose.conf.get("buildinstall_method")
self.used_lorax = self.buildinstall_method == 'lorax'
def skip(self): def skip(self):
if PhaseBase.skip(self): if PhaseBase.skip(self):
@ -120,7 +122,6 @@ class BuildinstallPhase(PhaseBase):
product = self.compose.conf["release_name"] product = self.compose.conf["release_name"]
version = self.compose.conf["release_version"] version = self.compose.conf["release_version"]
release = self.compose.conf["release_version"] release = self.compose.conf["release_version"]
buildinstall_method = self.compose.conf["buildinstall_method"]
disc_type = self.compose.conf['disc_types'].get('dvd', 'dvd') disc_type = self.compose.conf['disc_types'].get('dvd', 'dvd')
for arch in self.compose.get_arches(): for arch in self.compose.get_arches():
@ -132,7 +133,7 @@ class BuildinstallPhase(PhaseBase):
if final_output_dir != output_dir: if final_output_dir != output_dir:
repo_baseurl = translate_path(self.compose, repo_baseurl) repo_baseurl = translate_path(self.compose, repo_baseurl)
if buildinstall_method == "lorax": if self.buildinstall_method == "lorax":
buildarch = get_valid_arches(arch)[0] buildarch = get_valid_arches(arch)[0]
for variant in self.compose.get_variants(arch=arch, types=['variant']): for variant in self.compose.get_variants(arch=arch, types=['variant']):
if variant.is_empty: if variant.is_empty:
@ -142,7 +143,7 @@ class BuildinstallPhase(PhaseBase):
(variant, (variant,
self._get_lorax_cmd(repo_baseurl, output_dir, variant, arch, buildarch, volid)) self._get_lorax_cmd(repo_baseurl, output_dir, variant, arch, buildarch, volid))
) )
elif buildinstall_method == "buildinstall": elif self.buildinstall_method == "buildinstall":
volid = get_volid(self.compose, arch, disc_type=disc_type) volid = get_volid(self.compose, arch, disc_type=disc_type)
commands.append( commands.append(
(None, (None,
@ -156,7 +157,7 @@ class BuildinstallPhase(PhaseBase):
volid=volid)) volid=volid))
) )
else: else:
raise ValueError("Unsupported buildinstall method: %s" % buildinstall_method) raise ValueError("Unsupported buildinstall method: %s" % self.buildinstall_method)
for (variant, cmd) in commands: for (variant, cmd) in commands:
self.pool.add(BuildinstallThread(self.pool)) self.pool.add(BuildinstallThread(self.pool))
@ -164,11 +165,11 @@ class BuildinstallPhase(PhaseBase):
self.pool.start() self.pool.start()
def copy_files(self): def succeeded(self, variant, arch):
buildinstall_method = self.compose.conf["buildinstall_method"] return (variant.uid if self.used_lorax else None, arch) in self.pool.finished_tasks
disc_type = self.compose.conf['disc_types'].get('dvd', 'dvd')
used_lorax = buildinstall_method == 'lorax' def copy_files(self):
disc_type = self.compose.conf['disc_types'].get('dvd', 'dvd')
# copy buildinstall files to the 'os' dir # copy buildinstall files to the 'os' dir
kickstart_file = get_kickstart_file(self.compose) kickstart_file = get_kickstart_file(self.compose)
@ -176,7 +177,7 @@ class BuildinstallPhase(PhaseBase):
for variant in self.compose.get_variants(arch=arch, types=["self", "variant"]): for variant in self.compose.get_variants(arch=arch, types=["self", "variant"]):
if variant.is_empty: if variant.is_empty:
continue continue
if (variant.uid if used_lorax else None, arch) not in self.pool.finished_tasks: if not self.succeeded(variant, arch):
self.compose.log_debug( self.compose.log_debug(
'Buildinstall: skipping copying files for %s.%s due to failed runroot task' 'Buildinstall: skipping copying files for %s.%s due to failed runroot task'
% (variant.uid, arch)) % (variant.uid, arch))
@ -186,7 +187,7 @@ class BuildinstallPhase(PhaseBase):
# Lorax runs per-variant, so we need to tweak the source path # Lorax runs per-variant, so we need to tweak the source path
# to include variant. # to include variant.
if used_lorax: if self.used_lorax:
buildinstall_dir = os.path.join(buildinstall_dir, variant.uid) buildinstall_dir = os.path.join(buildinstall_dir, variant.uid)
if not os.path.isdir(buildinstall_dir) or not os.listdir(buildinstall_dir): if not os.path.isdir(buildinstall_dir) or not os.listdir(buildinstall_dir):