Repository: fedora-infra/bodhi

Issue:
Bodhi tags side-tag builds into f32-signing-pending
See https://koji.stg.fedoraproject.org/koji/buildinfo?buildID=1230137 which currently has this tag history:

````
nils@gibraltar:~> koji -p stg list-tag-history --build=atomic-reactor-1.6.33-6.fc32 
Fri Oct 25 12:05:17 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32-build-side-7889 by cverna
Fri Oct 25 12:07:22 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32-signing-pending by bodhi
Fri Oct 25 12:07:38 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32-build-side-7889-signing-pending by bodhi [still active]
Fri Oct 25 12:07:52 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32-updates-testing-pending by autopen [still active]
Fri Oct 25 12:07:52 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32-signing-pending by autopen
Fri Oct 25 12:31:09 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32-build-side-7889-testing-pending by bodhi [still active]
Fri Oct 25 12:33:07 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32-build-side-7889 by bodhi
Fri Oct 25 12:33:14 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 12:36:11 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 12:36:11 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 12:39:07 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 12:39:07 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 12:42:09 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 12:42:09 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 12:45:14 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 12:45:14 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 12:48:08 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 12:48:08 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 12:51:16 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 12:51:16 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 12:54:27 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 12:54:27 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 12:57:11 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 12:57:11 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:00:12 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:00:12 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:03:13 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:03:13 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:06:09 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:06:09 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:09:17 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:09:17 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:12:08 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:12:08 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:15:13 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:15:13 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:18:15 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:18:15 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:21:12 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:21:12 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:24:08 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:24:08 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:27:08 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi
Fri Oct 25 13:27:08 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:30:15 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32 by bodhi [still active]
Fri Oct 25 13:30:15 2019: atomic-reactor-1.6.33-6.fc32 untagged from f32 by bodhi
Fri Oct 25 13:30:36 2019: atomic-reactor-1.6.33-6.fc32 tagged into f32-updates-pending by bodhi [still active]
nils@gibraltar:~> 
````


Discussion:
So when we create a new update by default we request this update to be pushed to testing, this has for effect to tag the build in the fxx-update-signing-pending tag.

I think we need to skip the following line in the case of a sidetag update.

See https://github.com/fedora-infra/bodhi/blob/develop/bodhi/server/models.py#L2242




Resolving patch:
diff --git a/bodhi/server/models.py b/bodhi/server/models.py
--- a/bodhi/server/models.py
+++ b/bodhi/server/models.py
@@ -2256,8 +2256,9 @@ def new(cls, request, data):
                                f"release value of {up.mandatory_days_in_testing} days"
             })
 
-        log.debug("Setting request for new update.")
-        up.set_request(db, req, request.user.name)
+        if not data.get("from_tag"):
+            log.debug("Setting request for new update.")
+            up.set_request(db, req, request.user.name)
 
         log.debug("Adding new update to the db.")
         db.add(up)
@@ -2402,7 +2403,7 @@ def edit(cls, request, data):
         del(data['bugs'])
 
         req = data.pop("request", None)
-        if req is not None:
+        if req is not None and not data.get("from_tag"):
             up.set_request(db, req, request.user.name)
 
         for key, value in data.items():


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
@@ -302,15 +302,14 @@ def test_new_rpm_update_from_tag(self, *args):
         self.db.commit()
 
         update = self.get_update(builds=None, from_tag='f17-build-side-7777')
-        with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1), mock.patch(
-                'bodhi.server.buildsys.DevBuildsys.getTag', self.mock_getTag):
+        with mock.patch('bodhi.server.buildsys.DevBuildsys.getTag', self.mock_getTag):
             r = self.app.post_json('/updates/', update)
 
         up = r.json_body
         self.assertEqual(up['title'], 'gnome-backgrounds-3.0-1.fc17')
         self.assertEqual(up['builds'][0]['nvr'], 'gnome-backgrounds-3.0-1.fc17')
         self.assertEqual(up['status'], 'pending')
-        self.assertEqual(up['request'], 'testing')
+        self.assertEqual(up['request'], None)
         self.assertEqual(up['user']['name'], 'guest')
         self.assertEqual(up['release']['name'], 'F17')
         self.assertEqual(up['type'], 'bugfix')
@@ -350,7 +349,6 @@ def test_new_rpm_update_from_tag(self, *args):
                              'arches': None,
                              'maven_include_all': False,
                              'perm_id': 1})
-
         self.assertIn(expected_pending_signing, koji_session.__tags__)
         self.assertIn(expected_testing, koji_session.__tags__)
         self.assertIn(('f17-build-side-7777-signing-pending',
@@ -3017,8 +3015,7 @@ def test_edit_rpm_update_from_tag(self, *args):
         self.db.delete(BuildrootOverride.query.one())
 
         update = self.get_update(from_tag='f17-build-side-7777')
-        with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1):
-            r = self.app.post_json('/updates/', update)
+        r = self.app.post_json('/updates/', update)
 
         update['edited'] = r.json['alias']
         update['builds'] = 'bodhi-2.0.0-3.fc17'
@@ -3030,7 +3027,7 @@ def test_edit_rpm_update_from_tag(self, *args):
         up = r.json_body
         self.assertEqual(up['title'], 'bodhi-2.0.0-3.fc17')
         self.assertEqual(up['status'], 'pending')
-        self.assertEqual(up['request'], 'testing')
+        self.assertEqual(up['request'], None)
         self.assertEqual(up['user']['name'], 'guest')
         self.assertEqual(up['release']['name'], 'F17')
         self.assertEqual(up['type'], 'bugfix')