Repository: fedora-infra/bodhi

Issue:
Bodhi doesn't correctly mark updates as critpath updates for Rawhide
Rawhide updates are never identified as critpath updates:
https://bodhi.fedoraproject.org/updates/FEDORA-2021-c8f0463820
https://bodhi.fedoraproject.org/updates/FEDORA-2021-d8b1203333

The problem is in the interface with PDC:
https://github.com/fedora-infra/bodhi/blob/d275cc2bb9e513dc10e2009262adc989e199dadf/bodhi/server/models.py#L2103
and
https://github.com/fedora-infra/bodhi/blob/d275cc2bb9e513dc10e2009262adc989e199dadf/bodhi/server/util.py#L959

We query PDC for "name=f34", but rawhide in PDC is always "name=master"...


Discussion:
This PR / Issue was included in the 5.7.0 release of Bodhi, and is now deployed in Fedora Staging. Please verify and test that this works as expected.

https://bodhi.stg.fedoraproject.org/
This is not fixed.
The `Update.contains_critpath_component()` class method now works as expected, but I've just realized that the automatic_updates consumer doesn't check if the new update should be marked as critpath anywhere.

We'll need to add the appropriate flag into the update data.

Resolving patch:
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
@@ -185,6 +185,7 @@ def __call__(self, message: fedora_messaging.api.Message) -> None:
                 autokarma=False,
                 user=user,
                 status=UpdateStatus.pending,
+                critpath=Update.contains_critpath_component([build], rel.branch),
             )
 
             # Comment on the update that it was automatically created.


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
@@ -68,10 +68,17 @@ def setup_method(self, method):
 
     # Test the main code paths.
 
-    def test_consume(self, caplog):
+    @pytest.mark.parametrize('critpath', (True, False))
+    @mock.patch('bodhi.server.models.Update.contains_critpath_component')
+    def test_consume(self, contains, critpath, caplog):
         """Assert that messages about tagged builds create an update."""
         caplog.set_level(logging.DEBUG)
 
+        # The following is a really dirty hack
+        # We can't better mock things because 'util.get_critpath_components' uses a custom
+        # wrapper to "memoize" values that causes leakage between tests
+        contains.return_value = critpath
+
         # process the message
         self.handler(self.sample_message)
 
@@ -87,6 +94,10 @@ def test_consume(self, caplog):
         assert update.autokarma == False
         assert update.test_gating_status is None
         assert update.builds[0].release == self.release
+        if critpath:
+            assert update.critpath == True
+        else:
+            assert update.critpath == False
 
         expected_username = base.buildsys.DevBuildsys._build_data['owner_name']
         assert update.user and update.user.name == expected_username