#27 Update the open bugs when the corresponding package changes maintainer
Merged 4 years ago by nphilipp. Opened 4 years ago by pingou.
fedora-infra/ pingou/distgit-bugzilla-sync re-assign-bugs  into  master

@@ -13,6 +13,12 @@ 

      "Fedora Modules" = "Fedora Modules"

      "Fedora EPEL" = "Fedora EPEL"

  

+ [products_versions]

+     "Fedora" = ["rawhide", "31", "30", "29"]

+     "Fedora Container" = ["rawhide", "29"]

+     "Fedora Modules" = []

+     "Fedora EPEL" = ["epel8", "epel7", "el6"]

+ 

  [namespace_to_product]

      "rpms" = "Fedora"  # except EPEL...

      "container" = "Fedora Container"
@@ -23,6 +29,10 @@ 

      "modules" = "module"

      "container" = "container"

  

+ bz_maintainer_change_comment = """

+ This package has changed maintainer in the Fedora.

+ Reassigning to the new maintainer of this component.

+ """

  

  ## EMAIL TEMPLATES

  

@@ -234,6 +234,45 @@ 

          bz_email = email_overrides.get(bz_email, bz_email)

          return bz_email

  

+     def update_open_bugs(self, new_poc, prev_poc, product, name):

+         '''Change the package owner

+         :arg new_poc: email of the new point of contact.

+         :arg prev_poc: Username of the previous point of contact

+         :arg product: The product of the package to change in bugzilla

+         :arg name: Name of the package to change the owner.

+         '''

+         bz_query = {}

+         bz_query['product'] = product

+         bz_query['component'] = name

+         bz_query['bug_status'] = [

+             'NEW', 'ASSIGNED', 'ON_DEV', 'ON_QA', 'MODIFIED', 'POST',

+             'FAILS_QA', 'PASSES_QA', 'RELEASE_PENDING']

+         # Update only maintained releases

+         bz_query['version'] = self.config["products_versions"][product]

+ 

+         query_results = self.server.query(bz_query)

+ 

+         for bug in query_results:

+             if bug.assigned_to == prev_poc and bug.assigned_to != new_poc:

+                 if self.config["verbose"]:

+                     print(

+                         f'    - reassigning bug #{bug.bug_id} '

+                         f'from {bug.assigned_to} to {new_poc}'

+                     )

+                 if not self.config["dryrun"]:

+                     try:

+                         bug.setassignee(

+                             assigned_to=new_poc,

+                             comment=self.config['bz_maintainer_change_comment'],

+                         )

+                     except xmlrpc.client.Fault as e:

+                         # Output something useful in args

+                         e.args = (data, e.faultCode, e.faultString)

+                         raise

+                     except xmlrpc.client.ProtocolError as e:

+                         e.args = ('ProtocolError', e.errcode, e.errmsg)

+                         raise

+ 

      def add_edit_component(self, package, collection, owner, description=None,

                             qacontact=None, cclist=None, print_fas_names=False):

          '''Add or update a component to have the values specified.
@@ -344,6 +383,8 @@ 

                              else:

                                  print(f"    {key} changed from `{old_value}` to `{new_value}`")

  

+                 owner_changed = "initialowner" in data

+ 

                  # FIXME: initialowner has been made mandatory for some

                  # reason.  Asking dkl why.

                  data['initialowner'] = owner_email
@@ -357,6 +398,13 @@ 

                      except xmlrpc.client.ProtocolError as e:

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

                          raise

+                 if owner_changed:

+                     self.update_open_bugs(

+                         new_poc=owner_email,

+                         prev_poc=product[pkg_key]['initialowner'],

+                         name=package,

+                         product=self.config['products'][collection],

+                     )

              else:

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

                      print(f"[NOCHANGE] {package}/{self.config['products'][collection]}")

When a package change default assignee, go over all the open bugs and change their assignee as well.

Fixes https://pagure.io/fedora-infrastructure/issue/6940

This PR also contains a fix in the default configuration file. It seems multi-line strings should have a new line character just after the opening """.

Please remove this from the PR -- it seems to only change formatting and would clash with some restructuring coming up in my less-hard-coding PR.

Instead of setting this variable some lines above, and using it (only) here, let's merge it:

        if 'initialowner' in data:  # owner changed
            ...

Is there a way for us to pull this information from elsewhere, rather than having to (re)configure it every time we branch off a new release?

rebased onto 0e03634

4 years ago

Shouldn't we print this (or something similar) even if not dry-running, but only if verbose?

pdc and fpdc may or may not have this information, we may or may not be able to leverage some of the ansible variable when deploying this in openshift as well

Shouldn't we print this (or something similar) even if not dry-running, but only if verbose?

fair

2 new commits added

  • Update the open bugs when the corresponding package changes maintainer
  • Add the possibility to print when a package isn't going to be updated
4 years ago

Instead of setting this variable some lines above, and using it (only) here, let's merge it:
if 'initialowner' in data: # owner changed
...

I wanted to make sure we change the default assignee before re-assigning all the opened tickets.

pdc and fpdc may or may not have this information, we may or may not be able to leverage some of the ansible variable when deploying this in openshift as well

I've opened https://pagure.io/Fedora-Infra/distgit-bugzilla-sync/issue/28 so we don't loose track of this

This is too generic IMO, name it bz_maintainer_change_comment maybe?

Let's rename this to update_open_bugs(), as it is, it suggests it's about bugs that were opened by the script or similar when it's only about those that happen to be open at the moment.

rebased onto 8d3c488657c1d0e5bf2e2a016e1d54e5fc26498c

4 years ago

rebased onto 62e70e51a2598ff6a60766d214272a229b43eb60

4 years ago

rebased onto b1bb0c0

4 years ago

Metadata Update from @nphilipp:
- Request assigned

4 years ago

Pull-Request has been merged by nphilipp

4 years ago