Skip to content

Commit

Permalink
Unstuck builds in pending signing
Browse files Browse the repository at this point in the history
Signed-off-by: Mattia Verga <mattia.verga@tiscali.it>
  • Loading branch information
mattiaverga authored and AdamSaleh committed Nov 26, 2021
1 parent 2f400fd commit 2e52e3c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bodhi/server/buildsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ 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:
raise RuntimeError('Attempt to tag {} with None.'.format(build))
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:
Expand Down
15 changes: 15 additions & 0 deletions bodhi/server/tasks/check_signed_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def main():
return

kc = buildsys.get_session()
stuck_builds = []

for update in updates:
# Let Bodhi have its times
Expand All @@ -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()
10 changes: 9 additions & 1 deletion bodhi/tests/server/tasks/test_check_signed_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -119,14 +121,20 @@ 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()

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')
Expand Down
1 change: 1 addition & 0 deletions news/PR4300.bug
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2e52e3c

Please sign in to comment.