#83 On errors: output to stderr, exit with code 1
Merged a year ago by tdawson. Opened a year ago by tdawson.
centos/ tdawson/centpkg proper-error  into  develop

file modified
+27 -27
@@ -197,11 +197,11 @@ 

                      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

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

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

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

+                         self.log.error("Exiting")

+                         raise SystemExit(1)

                      divergent_branch = centpkg.utils.does_divergent_branch_exist(

                                              self.cmd.repo_name,

                                              rhel_version,
@@ -233,11 +233,11 @@ 

                          elif not divergent_branch and not in_stabilization :

                              temp_custom_user_metadata["rhel-target"] = "zstream"

                          else:

-                             self.log.info("We are currently in Stabalization mode")

-                             self.log.info("You must either set the rhel-target (--rhel-target)")

-                             self.log.info("or branch for the previous version.")

-                             self.log.info("Exiting")

-                             raise SystemExit

+                             self.log.error("We are currently in Stabalization mode")

+                             self.log.error("You must either set the rhel-target (--rhel-target)")

+                             self.log.error("or branch for the previous version.")

+                             self.log.error("Exiting")

+                             raise SystemExit(1)

                          self.args.custom_user_metadata = json.dumps(temp_custom_user_metadata)

                      else:

                          if divergent_branch:
@@ -245,21 +245,21 @@ 

                          elif not divergent_branch and not in_stabilization :

                              self.args.custom_user_metadata = '{"rhel-target": "zstream"}'

                          else:

-                             self.log.info("We are currently in Stabalization mode")

-                             self.log.info("You must either set the rhel-target (--rhel-target)")

-                             self.log.info("or branch for the previous version.")

-                             self.log.info("Exiting")

-                             raise SystemExit

+                             self.log.error("We are currently in Stabalization mode")

+                             self.log.error("You must either set the rhel-target (--rhel-target)")

+                             self.log.error("or branch for the previous version.")

+                             self.log.error("Exiting")

+                             raise SystemExit(1)

  

                      # Good to know

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

  

              else:

-                 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.error("NO INTERNAL CONFIGURATION")

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

+                 self.log.error("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.error("Exiting")

+                 raise SystemExit(1)

  

          # Proceed with build

          return super(centpkgClient, self)._build(sets)
@@ -291,12 +291,12 @@ 

          try:

              project = gl.projects.get(project_name_with_namespace)

          except gitlab.exceptions.GitlabGetError as e:

-             self.log.info("There is no repository with the given name. Did you spell it correctly?")

-             self.log.info("Fatal: ")

-             self.log.info(e)

-             raise SystemExit

+             self.log.error("There is no repository with the given name. Did you spell it correctly?")

+             self.log.error("Fatal: ")

+             self.log.error(e)

+             raise SystemExit(1)

          if not project.name == short_name:

-             self.log.info("Fatal: ")

-             self.log.info("Project name is wrong: " + short_name + " it should be: " + project.name)

-             raise SystemExit

+             self.log.error("Fatal: ")

+             self.log.error("Project name is wrong: " + short_name + " it should be: " + project.name)

+             raise SystemExit(1)

          super(centpkgClient, self).clone()

file modified
+3 -3
@@ -101,10 +101,10 @@ 

              status = super(StreamLookasideCache, self).remote_file_exists(

                  _name, filename, hashstr)

          except UploadError as e:

-             self.log.info('Error checking for %s at %s'

+             self.log.error('Error checking for %s at %s'

                            % (filename, self.upload_url))

-             self.log.info(e)

-             raise SystemExit

+             self.log.error(e)

+             raise SystemExit(1)

  

          return status

  

centpkg was erroring out with a code of 0
The errors were also being sent to stdout instead of stderr
This fixes that.

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

Pull-Request has been merged by tdawson

a year ago