#56 Drop bz_product_name override, don't always report configuration issue and other fixes
Merged 3 years ago by nphilipp. Opened 3 years ago by pingou.
fedora-infra/ pingou/distgit-bugzilla-sync fixes  into  master

@@ -12,11 +12,10 @@ 

  [products]

      [products.Fedora]

          namespace = "rpms"

-         versions = ["rawhide", "31", "30", "29"]

-     [products."Fedora Container"]

+         versions = ["rawhide", "33", "32", "31"]

+     [products."Fedora Container Images"]

          namespace = "container"

-         versions = ["rawhide", "29"]

-         bz_product_name = "Fedora Container Images"

+         versions = ["rawhide", "33", "32", "31"]

      [products."Fedora Modules"]

          namespace = "modules"

          versions = []

file modified
+30 -25
@@ -114,6 +114,7 @@ 

  

  

  class BugzillaProxy:

+ 

      def __init__(self, bz_server, username, password, config, pre_cache_users=True):

          self.bz_xmlrpc_server = bz_server

          self.username = username
@@ -168,31 +169,30 @@ 

                          raise

                      if self.config["verbose"]:

                          print(f"    ERROR {e}")

-                         print("    - Query failed, going to try again in 20 seconds")

-                     # Wait 20 seconds and try again

-                     time.sleep(20)

+                         print("    - Query failed, going to try again in 10 seconds")

+                     # Wait 10 seconds and try again

+                     time.sleep(10)

              return raw_data

  

          if self.config["bugzilla"]["compat_api"] == "getcomponentsdetails":

              # Old API -- in python-bugzilla.  But with current server, this

              # gives ProxyError

              for collection, product in self.config["products"].items():

-                 bz_product_name = product.get("bz_product_name", collection)

                  self.product_cache[collection] = self.server.getcomponentsdetails(

-                     bz_product_name

+                     collection

                  )

          elif self.config["bugzilla"]["compat_api"] == "component.get":

              # Way that's undocumented in the partner-bugzilla api but works

              # currently

              chunk = self.config["bugzilla"]["req_segment"]

              for collection, product in self.config["products"].items():

-                 bz_product_name = product.get("bz_product_name", collection)

+ 

                  # restrict the list of info returned to only the packages of

                  # interest

                  pkglist = [

                      project["name"]

                      for project in pagure_projects

-                     if bz_product_name in project["products"]

+                     if collection in project["products"]

                  ]

                  product_info_by_pkg = {}

                  estimated_size = math.ceil(len(pkglist) / chunk)
@@ -200,13 +200,13 @@ 

                      # Format that bugzilla will understand.  Strip None's that

                      # segment() pads out the final data segment() with

                      query = [

-                         {"product": bz_product_name, "component": p}

+                         {"product": collection, "component": p}

                          for p in pkg_segment

                          if p is not None

                      ]

                      if self.config["verbose"]:

                          print(

-                             f"  - Querying product `{bz_product_name}`, "

+                             f"  - Querying product `{collection}`, "

                              f"query {cnt} of {estimated_size}"

                          )

                      raw_data = _query_component(query)
@@ -384,9 +384,6 @@ 

              e.args = ("ProtocolError", e.errcode, e.errmsg)

              raise

  

-         bz_product_name = self.config["products"][collection].get(

-             "bz_product_name", collection

-         )

  

          # Set the qacontact_email and name

          default_qa_contact_email = self.config["default_qa_contact_email"]
@@ -431,7 +428,7 @@ 

  

              if data:

                  # Changes occurred.  Submit a request to change via xmlrpc

-                 data["product"] = bz_product_name

+                 data["product"] = collection

                  data["component"] = package

  

                  if self.config["verbose"]:
@@ -535,21 +532,21 @@ 

                          new_poc=owner_email,

                          prev_poc=product[pkg_key]["initialowner"],

                          name=package,

-                         product=bz_product_name,

+                         product=collection,

                          print_fas_names=print_fas_names,

                      )

              else:

                  if self.config.get("print-no-change"):

-                     print(f"[NOCHANGE] {package}/{bz_product_name}")

+                     print(f"[NOCHANGE] {package}/{collection}")

          else:

              if retired:

                  if self.config["verbose"]:

-                     print(f"[NOADD] {bz_product_name}/{package} (is retired)")

+                     print(f"[NOADD] {collection}/{package} (is retired)")

                  return

  

              # Add component

              data = {

-                 "product": bz_product_name,

+                 "product": collection,

                  "component": package,

                  "description": description or "NA",

                  "initialowner": owner_email,
@@ -579,12 +576,12 @@ 

                          else:

                              value = initial_cc_fasnames

                          print(

-                             f"[ADDCOMP] {bz_product_name}/{package}"

+                             f"[ADDCOMP] {collection}/{package}"

                              f"  {key} set to FAS name(s) `{value}`"

                          )

                      else:

                          print(

-                             f"[ADDCOMP] {bz_product_name}/{package}"

+                             f"[ADDCOMP] {collection}/{package}"

                              f"  {key} set to {data.get(key)}"

                          )

  
@@ -940,11 +937,16 @@ 

              if project["namespace"] not in self.env["pdc_types"]:

                  project["branches"] = []

                  project["products"] = []

-                 self.errors["configuration"].append(

-                     f'Namespace `{project["namespace"]}` not found in the pdc_type '

-                     f'configuration key, project {project["namespace"]}/{project["name"]} '

-                     "ignored"

-                 )

+                 error = f'Namespace `{project["namespace"]}` not found in the pdc_type ' \

+                     f'configuration key -- ignoring it'

+                 if not error in self.errors["configuration"]:

+                     self.errors["configuration"].append(error)

+                 if self.env["verbose"]:

+                     print(

+                         f'Namespace `{project["namespace"]}` not found in the pdc_type '

+                         f'configuration key, project {project["namespace"]}/{project["name"]} '

+                         "ignored"

+                     )

                  continue

  

              pdc_type = self.env["pdc_types"][project["namespace"]]
@@ -1159,7 +1161,10 @@ 

              if self.env["verbose"] or self.env["dryrun"]:

                  print("*" * 80)

                  print("\n".join(report))

-             if not self.env["dryrun"]:

+ 

+             # Do not send the email in dryrun or when the error only relates to

+             # configuration (which will always happen for flatpaks and tests)

+             if not self.env["dryrun"] and tuple(self.errors) != ("configuration",):

                  self.send_email(

                      self.env["email"]["from"],

                      self.env["email"]["notify_admins"],

You can shorten this to ... list(self.errors) == ["configuration"]:. When used in the context of a sequence, they keys of a dict get used anyway.

I don't think this code needs to be made faster, but just BTW, it's a habit of mine that if I don't plan to modify them (e.g. because I use the result once, then throw it away), I use tuples rather than lists which are more lightweight to create (and execute about 25% faster). This could be optimized further (but that's bordering on silly :wink:), by precomputing the dict_keys view and comparing it directly (which would be a third faster when executed many times).

Metadata Update from @nphilipp:
- Request assigned

3 years ago

4 new commits added

  • Update the versions available on bugzilla for the rpms and the containers
  • Only report namespace mis-configuration once and not always
  • Wait for 10 seconds instead of 20 when querying bugzilla failed
  • Drop the bz_product_name override
3 years ago

Pull-Request has been merged by nphilipp

3 years ago