Repository: fedora-infra/bodhi

Issue:
Wrong update instructions for rawhide
If one manually creates an update for rawhide, it doesn't auto-migrate.  So we need to chase karma, and the "how to install" instructions don't work, which is a problem.

Concretely, I have [this update](https://bodhi.fedoraproject.org/updates/FEDORA-2020-d5d4c21e87).  It happens to be pulling in a side-tag.  The instructions at the top are to run 

```sh
sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-d5d4c21e87
```

As far as I can tell, this will never work because the packages don't go there.  I'm actually not sure what the right invocation is, and would kind of like to know so that I can ask people to test.


Discussion:
To fix this we need to make a special condition in the update template for rawhide and modify the install instructions.

Rawhide in bodhi is identified as release that is not composed in bodhi (https://github.com/fedora-infra/bodhi/blob/develop/bodhi/server/models.py#L787)
Well, not so long ago this was not a problem, since all Rawhide builds were pushed directly in stable, so no updates were left in testing state.

Hiding the update command for all releases not composed by Bodhi would just be a short term fix. The real problem is that there isn't (I'm unaware of) a dnf command to easily install packages of an update pushed in testing from a side tag. It would require dnf to get the build list from the advisory and download packages directly from Koji, since no compose is made.

From what I can see, for Rawhide those packages are tagged with `sidetag-testing-pending`: why it isn't `sidetag-testing`? Is this the right workflow? Or maybe Bodhi is misbehaving here and when an update is created from a sidetag in Rawhide it should be pushed directly in stable?

Looking at https://docs.fedoraproject.org/en-US/rawhide-gating/multi-builds/ it seems that sidetag updates should not be left in Testing state. The update reported by the OP should have been moved to stable upon receiving Greenwave result, so definitely Bodhi is misbehaving here.
Ha I bet this is cause by https://github.com/fedora-infra/bodhi/issues/3912. If the autotime push is disabled when creating the update, it will get stuck in testing forever.

We need to make sure packager can't disable that option when creating an update.

@frozencemetery can you edit your update and enable auto push based on time ? that should make the update move to stable.
@abbra can you update https://bodhi.fedoraproject.org/updates/FEDORA-2020-d5d4c21e87 as suggested by cverna above?
Done. Not sure how long will it take to notice or we'll have to wait another couple days.
It is now pushed in stable 

Resolving patch:
diff --git a/bodhi/server/models.py b/bodhi/server/models.py
--- a/bodhi/server/models.py
+++ b/bodhi/server/models.py
@@ -2169,7 +2169,8 @@ def install_command(self) -> str:
         """
         Return the appropriate command for installing the Update.
 
-        There are three conditions under which the empty string is returned:
+        There are four conditions under which the empty string is returned:
+            * If the update is in testing status for rawhide.
             * If the update is not in a stable or testing repository.
             * If the release has not specified a package manager.
             * If the release has not specified a testing repository.
@@ -2177,6 +2178,9 @@ def install_command(self) -> str:
         Returns:
             The dnf command to install the Update, or the empty string.
         """
+        if not self.release.composed_by_bodhi and self.status == UpdateStatus.testing:
+            return ''
+
         if self.status != UpdateStatus.stable and self.status != UpdateStatus.testing:
             return ''
 
@@ -2259,6 +2263,12 @@ def new(cls, request, data):
         # Create the update
         log.debug("Creating new Update(**data) object.")
         release = data.pop('release', None)
+
+        if not release.composed_by_bodhi:
+            # For rawhide updates make sure autotime push is enabled
+            # https://github.com/fedora-infra/bodhi/issues/3912
+            data['autotime'] = True
+
         up = Update(**data, release=release)
 
         # We want to make sure that the value of stable_days


Test patch:
diff --git a/bodhi/tests/server/services/test_updates.py b/bodhi/tests/server/services/test_updates.py
--- a/bodhi/tests/server/services/test_updates.py
+++ b/bodhi/tests/server/services/test_updates.py
@@ -308,6 +308,9 @@ def test_new_rpm_update_from_tag(self, rawhide_workflow):
             self.db.commit()
 
         update = self.get_update(builds=None, from_tag='f17-build-side-7777')
+        # Let's test what happens if the user sets autotime to False
+        # Rawhide workflow must ignore this setting
+        update['autotime'] = False
         with mock.patch('bodhi.server.buildsys.DevBuildsys.getTag', self.mock_getTag):
             r = self.app.post_json('/updates/', update)
 
@@ -333,6 +336,10 @@ def test_new_rpm_update_from_tag(self, rawhide_workflow):
         assert up['karma'] == 0
         assert up['requirements'] == 'rpmlint'
         assert up['from_tag'] == 'f17-build-side-7777'
+        if rawhide_workflow:
+            assert up['autotime'] is True
+        else:
+            assert up['autotime'] is False
 
         resp = self.app.get(f"/updates/{up['alias']}", headers={'Accept': 'text/html'})
 
diff --git a/bodhi/tests/server/test_models.py b/bodhi/tests/server/test_models.py
--- a/bodhi/tests/server/test_models.py
+++ b/bodhi/tests/server/test_models.py
@@ -1906,6 +1906,21 @@ def test_cannot_install(self):
 
         assert update.install_command == ''
 
+    def test_cannot_install_rawhide_testing(self):
+        """Update is in testing state and is for Rawhide.
+
+        This should be a temporary state, however, since it's not available
+        in any repository, just don't show a wrong update command.
+        """
+        update = model.Update.query.first()
+        update.status = UpdateStatus.testing
+        update.type = UpdateType.bugfix
+        update.release.package_manager = PackageManager.dnf
+        update.release.testing_repository = 'updates-testing'
+        update.release.composed_by_bodhi = False
+
+        assert update.install_command == ''
+
     def test_update_command_not_possible_missing_packagemanager(self):
         """The Release of the Update misses the package manager definition."""
         update = model.Update.query.first()