#74 Better error message when phase determining fails
Merged 2 years ago by tdawson. Opened 2 years ago by tdawson.
centos/ tdawson/centpkg better-error  into  develop

file modified
+14 -8
@@ -159,7 +159,7 @@ 

      def _build(self, sets=None):

  

          # Only do rhel-target if we are centpkg, not centpkg-sig

-         if not os.path.basename(sys.argv[0]).endswith('-sig'):

+         if not os.path.basename(sys.argv[0]).endswith('-sig') and not self.args.scratch:

  

              # Only run if we have internal configuraions, or scratch

              internal_config_file = "/etc/rpkg/centpkg_internal.conf"
@@ -193,7 +193,14 @@ 

                      self.log.info("Checking rhel-target information:")

                      stream_version = self.cmd.target.split('-')[0]

                      rhel_version = centpkg.utils.stream_mapping(stream_version)

-                     active_y, in_stabilization = centpkg.utils.determine_active_y_version(rhel_version, pp_api_url)

+                     try:

+                         active_y, in_stabilization = centpkg.utils.determine_active_y_version(rhel_version, pp_api_url)

+                     except AssertionError as e:

+                         self.log.info("  Error: centpkg cannot determine the development phase.")

+                         self.log.info("         Please file an issue at https://git.centos.org/centos/centpkg")

+                         self.log.info("  Workaround: Use the --rhel-target option")

+                         self.log.info("Exiting")

+                         raise SystemExit

                      divergent_branch = centpkg.utils.does_divergent_branch_exist(

                                              self.cmd.repo_name,

                                              rhel_version,
@@ -247,12 +254,11 @@ 

                      self.log.info("    rhel-target: " + json.loads(self.args.custom_user_metadata)['rhel-target'])

  

              else:

-                 if not self.args.scratch:

-                     self.log.info("NO INTERNAL CONFIGURATION")

-                     self.log.info("Only scratch builds are allowed without internal configurations")

-                     self.log.info("Hint: Install the rhel-packager package from https://download.devel.redhat.com/rel-eng/RCMTOOLS/latest-RCMTOOLS-2-RHEL-9/compose/BaseOS/x86_64/os/Packages/ if you want to build the package via internal (Red Hat) configuration.")

-                     self.log.info("Exiting")

-                     raise SystemExit

+                 self.log.info("NO INTERNAL CONFIGURATION")

+                 self.log.info("Only scratch builds are allowed without internal configurations")

+                 self.log.info("Hint: Install the rhel-packager package from https://download.devel.redhat.com/rel-eng/RCMTOOLS/latest-RCMTOOLS-2-RHEL-9/compose/BaseOS/x86_64/os/Packages/ if you want to build the package via internal (Red Hat) configuration.")

+                 self.log.info("Exiting")

+                 raise SystemExit

  

          # Proceed with build

          return super(centpkgClient, self)._build(sets)

Currently, if centpkg is unable to determine what development phase we are in, it just skips it and moves on.
This causes the next error to be very vague.
This pull request catches the Assertion Error, tells you what is wrong, where to file a bug, and how to work around the problem.
Also, when doing a scratch build, this check isn't needed.

Signed-off-by: Troy Dawson tdawson@redhat.com

1 new commit added

  • do not check with scratch builds
2 years ago

Pull-Request has been merged by tdawson

2 years ago
Metadata