Repository: fedora-infra/bodhi

Issue:
ELN bodhi updates closing Fedora rawhide bugzillas
== From https://pagure.io/fedora-infrastructure/issue/9191

I've just seen an ELN update close my rawhide Bugzilla:

https://bugzilla.redhat.com/show_bug.cgi?id=1856103

While this bugzilla is now technically rightfully closed because of the mass rebuild, I find it confusing that the ELN update closes a Fedora rawhide bugzilla.

Is this integration enabled for ELN updates intentionally?

====￼ 

pingou commented 4 hours ago
￼
￼
￼
The corresponding bodhi updates points to that bugzilla ticket: https://bodhi.fedoraproject.org/updates/FEDORA-2020-3ff70cd141

I don't think that bodhi does any logic as to whether it should close a rawhide bugzilla ticket for a F32/31/33 update. I suspect it leaves that problem to humans and just close the tickets it is instructed to close.

￼ pingou commented 4 hours ago
￼
￼
￼
And the mass-rebuild by-passing bodhi, it would not have been able to close that ticket.

The base of what happened is documented at https://github.com/fedora-infra/bodhi/blob/develop/docs/user/automatic_updates.rst#associate-bugs-to-automatic-updates





Discussion:
I honestly don't think there is anything to do here.
What happened here is that the mass rebuild did actually by-pass Bodhi: python-argcomplete-1.12.0-2.fc33 was built by mass rebuild and did not pass though Bodhi workflow, so the bugzilla ticket wasn't closed inside a F33 update.

After that, an automated task from jenkins fired a build for ELN, the automatic update got created inside Bodhi, which in turn attached the bugzilla ticket that was still open...

This is a really unusual case, I thought in the past about doing a check between the Bodhi release and the bugzilla ticket release, but that would be a lot of work and I think many users would then complain about bugs not being attached/closed...
Based on @mattiaverga explanation I would be +1 to close
In this specific case only the ELN update closed the bugzilla because it happened during the mass rebuild.

However, Id' like to opt out form the ELN updates commenting in my packages. Is that possible?

If I choose to use the "Fixes: rhbz#xxx" changelog entries, the ELN builds will spam my rawhide bugzillas.
The only way to not make that happen is to not use such comments in changelogs and close my bugzillas manually?
> The only way to not make that happen is to not use such comments in changelogs and close my bugzillas manually?

Or manually link the update to the bugzilla tickets (and then bodhi will close the ticket as it does normally).
When things work, the update is pushed to stable before I can edit it to add the bugzilla link.
I'd like to +1 this, please don't close bugs when ELN builds get pushed. There's no way to prevent this from a packager perspective and all it does is create bugzilla spam for every rawhide update.

Resolving patch:
diff --git a/bodhi/server/config.py b/bodhi/server/config.py
--- a/bodhi/server/config.py
+++ b/bodhi/server/config.py
@@ -275,6 +275,9 @@ class BodhiConfig(dict):
         'buildsystem': {
             'value': 'dev',
             'validator': str},
+        'bz_exclude_rels': {
+            'value': [],
+            'validator': _generate_list_validator(',')},
         'bz_products': {
             'value': ['Fedora', 'Fedora EPEL', 'Fedora Modules'],
             'validator': _generate_list_validator(',')},
diff --git a/bodhi/server/consumers/automatic_updates.py b/bodhi/server/consumers/automatic_updates.py
--- a/bodhi/server/consumers/automatic_updates.py
+++ b/bodhi/server/consumers/automatic_updates.py
@@ -161,16 +161,17 @@ def __call__(self, message: fedora_messaging.api.Message) -> None:
 {changelog}
 ```"""
 
-                for b in re.finditer(config.get('bz_regex'), changelog, re.IGNORECASE):
-                    idx = int(b.group(1))
-                    log.debug(f'Adding bug #{idx} to the update.')
-                    bug = Bug.get(idx)
-                    if bug is None:
-                        bug = Bug(bug_id=idx)
-                        dbsession.add(bug)
-                        dbsession.flush()
-                    if bug not in closing_bugs:
-                        closing_bugs.append(bug)
+                if rel.name not in config.get('bz_exclude_rels'):
+                    for b in re.finditer(config.get('bz_regex'), changelog, re.IGNORECASE):
+                        idx = int(b.group(1))
+                        log.debug(f'Adding bug #{idx} to the update.')
+                        bug = Bug.get(idx)
+                        if bug is None:
+                            bug = Bug(bug_id=idx)
+                            dbsession.add(bug)
+                            dbsession.flush()
+                        if bug not in closing_bugs:
+                            closing_bugs.append(bug)
             else:
                 notes = f"Automatic update for {bnvr}."
             update = Update(


Test patch:
diff --git a/bodhi/tests/server/consumers/test_automatic_updates.py b/bodhi/tests/server/consumers/test_automatic_updates.py
--- a/bodhi/tests/server/consumers/test_automatic_updates.py
+++ b/bodhi/tests/server/consumers/test_automatic_updates.py
@@ -150,6 +150,32 @@ def test_bug_added(self, mock_generate_changelog):
         assert len(update.bugs) > 0
         assert update.bugs[0].bug_id == 112233
 
+    @mock.patch.dict(config, [('bz_exclude_rels', ['F17'])])
+    @mock.patch('bodhi.server.models.RpmBuild.get_changelog')
+    def test_bug_not_added_excluded_release(self, mock_generate_changelog):
+        """Assert that a bug is not added for excluded release."""
+        changelog = ('* Sat Aug  3 2013 Fedora Releng <rel-eng@lists.fedoraproject.org> - 2\n'
+                     '- Added a free money feature.\n- Fix rhbz#112233.')
+
+        mock_generate_changelog.return_value = changelog
+
+        # process the message
+        self.handler(self.sample_message)
+
+        # check if the update exists...
+        update = self.db.query(Update).filter(
+            Update.builds.any(Build.nvr == self.sample_nvr)
+        ).first()
+
+        assert update.notes == f"""Automatic update for colord-1.3.4-1.fc26.
+
+##### **Changelog**
+
+```
+{changelog}
+```"""
+        assert len(update.bugs) == 0
+
     @mock.patch('bodhi.server.models.RpmBuild.get_changelog')
     def test_changelog_handled_exception(self, mock_generate_changelog):
         """Assert that update creation is succesful if get_changelog() raises ValueError."""