#832 buildinstall: Fix treeinfo generating on failure
Merged 6 years ago by lsedlar. Opened 6 years ago by lsedlar.
lsedlar/pungi failed-buildinstall  into  master

file modified
+1 -1
@@ -397,7 +397,7 @@ 

      # write treeinfo before ISOs are created

      for variant in compose.get_variants():

          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

      for variant in compose.get_variants():

file modified
+2 -2
@@ -185,7 +185,7 @@ 

      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:

          return

  
@@ -288,7 +288,7 @@ 

              self.release = LoraxProduct(self)

  

      # images

-     if variant.type == "variant":

+     if variant.type == "variant" and bi.succeeded(variant, arch):

          os_tree = compose.paths.compose.os_tree(arch, variant)

  

          # clone all but 'general' sections from buildinstall .treeinfo

file modified
+10 -9
@@ -45,6 +45,8 @@ 

          # A set of (variant_uid, arch) pairs that completed successfully. This

          # is needed to skip copying files for failed tasks.

          self.pool.finished_tasks = set()

+         self.buildinstall_method = self.compose.conf.get("buildinstall_method")

+         self.used_lorax = self.buildinstall_method == 'lorax'

  

      def skip(self):

          if PhaseBase.skip(self):
@@ -120,7 +122,6 @@ 

          product = self.compose.conf["release_name"]

          version = 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')

  

          for arch in self.compose.get_arches():
@@ -132,7 +133,7 @@ 

              if final_output_dir != output_dir:

                  repo_baseurl = translate_path(self.compose, repo_baseurl)

  

-             if buildinstall_method == "lorax":

+             if self.buildinstall_method == "lorax":

                  buildarch = get_valid_arches(arch)[0]

                  for variant in self.compose.get_variants(arch=arch, types=['variant']):

                      if variant.is_empty:
@@ -142,7 +143,7 @@ 

                          (variant,

                           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)

                  commands.append(

                      (None,
@@ -156,7 +157,7 @@ 

                                                  volid=volid))

                  )

              else:

-                 raise ValueError("Unsupported buildinstall method: %s" % buildinstall_method)

+                 raise ValueError("Unsupported buildinstall method: %s" % self.buildinstall_method)

  

              for (variant, cmd) in commands:

                  self.pool.add(BuildinstallThread(self.pool))
@@ -164,19 +165,19 @@ 

  

          self.pool.start()

  

+     def succeeded(self, variant, arch):

+         return (variant.uid if self.used_lorax else None, arch) in self.pool.finished_tasks

+ 

      def copy_files(self):

-         buildinstall_method = self.compose.conf["buildinstall_method"]

          disc_type = self.compose.conf['disc_types'].get('dvd', 'dvd')

  

-         used_lorax = buildinstall_method == 'lorax'

- 

          # copy buildinstall files to the 'os' dir

          kickstart_file = get_kickstart_file(self.compose)

          for arch in self.compose.get_arches():

              for variant in self.compose.get_variants(arch=arch, types=["self", "variant"]):

                  if variant.is_empty:

                      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(

                          'Buildinstall: skipping copying files for %s.%s due to failed runroot task'

                          % (variant.uid, arch))
@@ -186,7 +187,7 @@ 

  

                  # Lorax runs per-variant, so we need to tweak the source path

                  # to include variant.

-                 if used_lorax:

+                 if self.used_lorax:

                      buildinstall_dir = os.path.join(buildinstall_dir, variant.uid)

  

                  if not os.path.isdir(buildinstall_dir) or not os.listdir(buildinstall_dir):

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.

rebased onto 61a3be2

6 years ago

Pull-Request has been merged by lsedlar

6 years ago