diff --git a/bodhi/server/buildsys.py b/bodhi/server/buildsys.py index 5d9d520e61..d4df390ae8 100644 --- a/bodhi/server/buildsys.py +++ b/bodhi/server/buildsys.py @@ -153,6 +153,7 @@ def moveBuild(self, from_tag: str, to_tag: str, build: str, *args, **kw): log.debug("moveBuild(%s, %s, %s)" % (from_tag, to_tag, build)) DevBuildsys.__moved__.append((from_tag, to_tag, build)) + @multicall_enabled def tagBuild(self, tag: str, build: str, *args, **kw): """Emulate Koji's tagBuild.""" if tag is None: @@ -160,6 +161,7 @@ def tagBuild(self, tag: str, build: str, *args, **kw): log.debug("tagBuild(%s, %s)" % (tag, build)) DevBuildsys.__added__.append((tag, build)) + @multicall_enabled def untagBuild(self, tag: str, build: str, *args, **kw): """Emulate Koji's untagBuild.""" if tag is None: diff --git a/bodhi/server/tasks/check_signed_builds.py b/bodhi/server/tasks/check_signed_builds.py index 3b315bedf0..eeb5db0afa 100644 --- a/bodhi/server/tasks/check_signed_builds.py +++ b/bodhi/server/tasks/check_signed_builds.py @@ -60,6 +60,7 @@ def main(): return kc = buildsys.get_session() + stuck_builds = [] for update in updates: # Let Bodhi have its times @@ -80,6 +81,20 @@ def main(): continue build_tags = [t['name'] for t in kc.listTags(build=build.nvr)] if pending_signing_tag not in build_tags and pending_testing_tag in build_tags: + # Our composer missed the message that the build got signed log.debug(f'Changing signed status of {build.nvr}') build.signed = True + if pending_signing_tag in build_tags and pending_testing_tag not in build_tags: + # autosign missed the message that the build is waiting to be signed + log.debug(f'{build.nvr} is stuck waiting to be signed, let\'s try again') + stuck_builds.append(build.nvr) session.flush() + + if stuck_builds: + kc.multicall = True + for b in stuck_builds: + kc.untagBuild(pending_signing_tag, b, force=True) + kc.multiCall() + for b in stuck_builds: + kc.tagBuild(pending_signing_tag, b, force=True) + kc.multiCall() diff --git a/bodhi/tests/server/tasks/test_check_signed_builds.py b/bodhi/tests/server/tasks/test_check_signed_builds.py index af4eb37afc..4d65b9ab1e 100644 --- a/bodhi/tests/server/tasks/test_check_signed_builds.py +++ b/bodhi/tests/server/tasks/test_check_signed_builds.py @@ -109,6 +109,8 @@ def test_check_signed_builds_ignore_signed_builds(self, debug, buildsys): def test_check_signed_builds_still_not_signed(self, debug, buildsys): """ The task should NOT mark signed builds if it is still pending-signing. + + Instead it should try to resubmit the builds to signing. """ update = models.Update.query.first() update.builds[0].signed = False @@ -119,7 +121,7 @@ def test_check_signed_builds_still_not_signed(self, debug, buildsys): {'arches': 'i386 x86_64 ppc ppc64', 'id': 10, 'locked': True, 'name': 'f17-updates-candidate', 'perm': None, 'perm_id': None}, {'arches': 'i386 x86_64 ppc ppc64', 'id': 10, 'locked': True, - 'name': 'f17-signing-pending', 'perm': None, 'perm_id': None}, ] + 'name': 'f17-updates-signing-pending', 'perm': None, 'perm_id': None}, ] buildsys.get_session.return_value.listTags.return_value = listTags check_signed_builds_main() @@ -127,6 +129,12 @@ def test_check_signed_builds_still_not_signed(self, debug, buildsys): update = models.Update.query.first() buildsys.get_session.assert_called_once() assert update.builds[0].signed == False + debug.assert_called_once_with('bodhi-2.0-1.fc17 is stuck waiting to be signed, ' + 'let\'s try again') + buildsys.get_session.return_value.untagBuild.assert_called_once_with( + 'f17-updates-signing-pending', 'bodhi-2.0-1.fc17', force=True) + buildsys.get_session.return_value.tagBuild.assert_called_once_with( + 'f17-updates-signing-pending', 'bodhi-2.0-1.fc17', force=True) @patch('bodhi.server.tasks.check_signed_builds.buildsys') @patch('bodhi.server.tasks.check_signed_builds.log.debug') diff --git a/news/PR4300.bug b/news/PR4300.bug new file mode 100644 index 0000000000..539c6910ef --- /dev/null +++ b/news/PR4300.bug @@ -0,0 +1 @@ +Bodhi will now try to resubmit a build to signing if it detects that is stuck in pending signing for some time