#24 Ensure the API returns a valid code before proceeding and add missing import
Closed 2 years ago by asaleh. Opened 3 years ago by pingou.
fedora-ci/ pingou/monitor-gating staging  into  master

@@ -123,7 +123,7 @@ 

  

          if not updateid:

              utils.finalize(start)

-             return

+             return utils

  

          # Check that bodhi notified the pipeline it can run

          utils.lookup_results_datagrepper(

file modified
+14 -2
@@ -18,7 +18,7 @@ 

  

  from . import multi_builds

  from . import single_build

- from .utils import MonitoringUtils, blocking_issues, run_command

+ from .utils import MonitoringUtils, blocking_issues, run_command, report_failure

  

  

  s = sched.scheduler(time.time, time.sleep)
@@ -45,8 +45,12 @@ 

          print(f"Fedora Messaging broker rejected message {msg.id}: {err}")

      except fedora_messaging.exceptions.ConnectionException as err:

          print(f"Error sending message {msg.id}: {err}")

+         print(f"topic: {topic}")

+         print(f"message: {message}")

      except Exception as err:

          print(f"Error sending fedora-messaging message: {err}")

+         print(f"topic: {topic}")

+         print(f"message: {message}")

  

  

  def _clean_up_side_tags(utils):
@@ -145,9 +149,17 @@ 

      except Exception as err:

          print(f"Tests failed with: {err}", flush=True)

          print(sys.exc_info()[0])

+         print("-"*60)

+         print(sys.exc_info())

+         print("="*60)

+         import traceback

+         traceback.print_exc(file=sys.stdout)

+         print("-"*60)

+         traceback.print_stack()

+ 

  

          notify(

-             topic=f"multi-build.end.error", message={"runid": runid, "exception": err},

+             topic=f"multi-build.end.error", message={"runid": runid, "exception": str(err)},

          )

  

      delay_when_failing = conf["delay_when_failing"]

file modified
+32 -27
@@ -37,7 +37,7 @@ 

  

      data = {

          "title": title,

-         "content": content,

+         "issue_content": content,

          "tag": tag,

      }

      headers = {
@@ -46,7 +46,9 @@ 

  

      req = requests.post(url, data=data, headers=headers)

      if not req.ok:

-         print(f"Error when trying to open a ticket at: {url} to report the failure")

+         print(f"Error when trying to open a ticket at: {url} to report the failure", flush=True)

+         print(f"Request to {url} with data={data} returned: {req.status_code}", flush=True)

+         print(f"Output: {req.text}", flush=True)

  

  

  def blocking_issues(project, tags):
@@ -60,14 +62,17 @@ 

      issues = []

      try:

          r = requests.get(api)

-         issues = r.json()["issues"]

-         if tags:

-             t = set(tags[1:])

-             issues = [i for i in issues if t & set(i["tags"])]

-         for i in issues:

-             print(f"Found blocking issue https://pagure.io/{project}/issue/{i['id']}")

+         if not r.ok:

+             print(f"Failed to query: {api} -- returned : {r.status_code}", flush=True)

+         else:

+             issues = r.json()["issues"]

+             if tags:

+                 t = set(tags[1:])

+                 issues = [i for i in issues if t & set(i["tags"])]

+             for i in issues:

+                 print(f"Found blocking issue https://pagure.io/{project}/issue/{i['id']}", flush=True)

      except Exception as e:

-         print(f"Error when querying pagure for blocking issues: {e}")

+         print(f"Error when querying pagure for blocking issues: {e}", flush=True)

      return issues

  

  
@@ -153,7 +158,7 @@ 

              run_command([command, "switch-branch", f"{name}"], cwd=folder)

              self.print_user(info_log, success=True)

          except MonitoringException:

-             self.failed("fedpkg")

+             self.failed.append("fedpkg")

              self.print_user(info_log, success=False)

  

      def bump_release(self, name, folder):
@@ -165,7 +170,7 @@ 

              run_command(["rpmdev-bumpspec", f"{name}.spec"], cwd=folder)

              self.print_user(info_log, success=True)

          except MonitoringException:

-             self.failed("rpmdev-bumspec")

+             self.failed.append("rpmdev-bumpspec")

              self.print_user(info_log, success=False)

  

      def commit_changes(self, commit_log, folder):
@@ -178,7 +183,7 @@ 

              run_command(["git", "commit", "-asm", commit_log], cwd=folder)

              self.print_user(info_log, success=True)

          except MonitoringException:

-             self.failed("git")

+             self.failed.append("git")

              self.print_user(info_log, success=False)

  

      def push_changes(self, folder, target, branch, force=False):
@@ -193,7 +198,7 @@ 

              run_command(cmd, cwd=folder)

              self.print_user(info_log, success=True)

          except MonitoringException:

-             self.failed("git/dist-git")

+             self.failed.append("git/dist-git")

              self.print_user(info_log, success=False)

  

      def pull_changes(self, folder, target, branch):
@@ -206,7 +211,7 @@ 

              run_command(cmd, cwd=folder)

              self.print_user(info_log, success=True)

          except MonitoringException:

-             self.failed("git/dist-git")

+             self.failed.append("git/dist-git")

              self.print_user(info_log, success=False)

  

      def open_pullrequest(self, base_url, username, namespace, name, branch, token):
@@ -234,7 +239,7 @@ 

              success = False

              pr_id = None

              pr_uid = None

-             self.failed("dist-git")

+             self.failed.append("dist-git")

          else:

              output = req.json()

              pr_id = str(output["id"])
@@ -257,7 +262,7 @@ 

              self.print_user(info_log, success=True)

              return nevr.strip().decode("utf-8")

          except MonitoringException:

-             self.failed("fedpkg")

+             self.failed.append("fedpkg")

              self.print_user(info_log, success=False)

  

      def build_package(self, command, folder, target=None):
@@ -272,7 +277,7 @@ 

              run_command(command, cwd=folder)

              self.print_user(info_log, success=True)

          except MonitoringException:

-             self.failed("koji")

+             self.failed.append("koji")

              self.print_user(info_log, success=False)

  

      def chain_build_packages(self, command, packages, folder, target=None):
@@ -292,7 +297,7 @@ 

              run_command(command, cwd=folder)

              self.print_user(info_log, success=True)

          except MonitoringException:

-             self.failed("koji")

+             self.failed.append("koji")

              self.print_user(info_log, success=False)

  

      def get_build_tags(self, koji_url, nevr, expected_ends):
@@ -350,7 +355,7 @@ 

  

          info_log = f"Retrieving koji tags: {tags}"

          if not success:

-             self.failed("koji")

+             self.failed.append("koji")

          self.print_user(info_log, success=success)

  

      def create_update(
@@ -384,7 +389,7 @@ 

              run_command(command)

              self.print_user(info_log, success=True)

          except MonitoringException:

-             self.failed("bodhi")

+             self.failed.append("bodhi")

              self.print_user(info_log, success=False)

  

      def get_update_id(self, nevr, url):
@@ -405,7 +410,7 @@ 

  

              if (datetime.datetime.utcnow() - start).seconds > (15 * 60):

                  success = False

-                 self.failed("bodhi")

+                 self.failed.append("bodhi")

                  info_log = f"Update for {nevr} not created within 15 minutes"

                  break

  
@@ -565,7 +570,7 @@ 

          info_log += f" - ran for: {(end - start_lookup).seconds}s"

          self.print_user(info_log, success=success)

          if not success:

-             self.failed("datagrepper")

+             self.failed.append("datagrepper")

  

      def lookup_ci_resultsdb(self, nevr, name, url):

          """ Check the CI results in the specified resultsdb for results about
@@ -616,7 +621,7 @@ 

          info_log += f" - ran for: {(end - start).seconds}s"

          self.print_user(info_log, success=success)

          if not success:

-             self.failed("resultsdb")

+             self.failed.append("resultsdb")

  

      def waive_update(self, command, updateid, prod=True, username=None, password=None):

          """ Waive all the tests results for the specified update using bodhi's
@@ -642,7 +647,7 @@ 

              run_command(command)

              self.print_user(info_log, success=True)

          except MonitoringException:

-             self.failed("waiverdb")

+             self.failed.append("waiverdb")

              self.print_user(info_log, success=False)

  

      def get_pr_flag(
@@ -698,7 +703,7 @@ 

  

          self.print_user(info_log, success=success)

          if not success:

-             self.failed("dist-git")

+             self.failed.append("dist-git")

  

      def merge_pr(self, base_url, username, namespace, name, pr_id, token):

          """ Merge the specified PR
@@ -719,7 +724,7 @@ 

  

          self.print_user(info_log, success=success)

          if not success:

-             self.failed("dist-git")

+             self.failed.append("dist-git")

  

      def finalize(self, start):

          """ End data returned. """
@@ -742,7 +747,7 @@ 

              self.print_user(info_log, success=True)

          except (MonitoringException, Exception) as err:

              print(err)

-             self.failed("dist-git")

+             self.failed.append("dist-git")

              self.print_user(info_log, success=False)

          return side_tag_name

  

no initial comment

The first commit needs to be removed before this PR can be merged, only the other commits are of interest here.

Metadata Update from @nphilipp:
- Request assigned

3 years ago

Looks good to me, but as discussed let's leave this open until it got some more testing.

1 new commit added

  • When notifying on errors, don't send the raw error object, send its text version
3 years ago

1 new commit added

  • Flush some prints
3 years ago

1 new commit added

  • Add some more debugging
3 years ago

2 new commits added

  • Fix typo in the rpmdev-bumpspec name
  • Fix appending an element to a list rather than trying to call the list
3 years ago

1 new commit added

  • Be more specific about the error
3 years ago

9 new commits added

  • Be more specific about the error
  • Fix typo in the rpmdev-bumpspec name
  • Fix appending an element to a list rather than trying to call the list
  • Add some more debugging
  • Flush some prints
  • When notifying on errors, don't send the raw error object, send its text version
  • Add missing import to the runner.py
  • Check that the request return a 2xx code before proceeding
  • Add more debugging
3 years ago

1 new commit added

  • Fix field name when opening an issue on pagure
3 years ago

1 new commit added

  • Fix returning the MonitorUtils object
3 years ago

rebased onto ad0f320

3 years ago

Pull-Request has been closed by asaleh

2 years ago