Skip to content

Commit

Permalink
Unstuck side_tag updates when builds are ejected from composes
Browse files Browse the repository at this point in the history
Signed-off-by: Mattia Verga <[email protected]>
  • Loading branch information
mattiaverga committed Feb 9, 2025
1 parent 2416c1f commit a305571
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bodhi-server/bodhi/server/tasks/check_signed_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

from bodhi.server import buildsys, models
from bodhi.server.config import config
from bodhi.server.tasks import handle_side_and_related_tags_task
from bodhi.server.util import transactional_session_maker


Expand Down Expand Up @@ -79,15 +80,30 @@ def main():
continue
pending_signing_tag = update.release.pending_signing_tag
pending_testing_tag = update.release.pending_testing_tag
candidate_tag = update.release.candidate_tag
for build in builds:
build_tags = [t['name'] for t in kc.listTags(build=build.nvr)]
if build.signed:
log.debug(f'{build.nvr} already marked as signed')
# We need to "unsign" the build in Bodhi database, otherwise the
# signed consumer will ignore the message and stops the flow
build.signed = False
session.flush()
if (update.release.testing_tag in build_tags
and update.release.candidate_tag not in build_tags):
# The update was probably ejected from a compose and is stuck
log.debug(f'Resubmitting {update.alias} to testing')
update.set_request(session, models.UpdateRequest.testing, 'bodhi')
if update.from_tag:
side_tag = update.from_tag
update.untag(session)
builds = [b.nvr for b in update.builds]
handle_side_and_related_tags_task.delay(
builds=builds,
pending_signing_tag=pending_signing_tag,
from_tag=side_tag,
candidate_tag=candidate_tag)
else:
update.set_request(session, models.UpdateRequest.testing, 'bodhi')
break
continue
if pending_signing_tag not in build_tags and pending_testing_tag in build_tags:
Expand Down
37 changes: 37 additions & 0 deletions bodhi-server/tests/tasks/test_check_signed_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,43 @@ def test_check_signed_builds_stuck_Update_with_signed_build(self, debug, buildsy
call(f'Resubmitting {update.alias} to testing')]
debug.assert_has_calls(calls)
request.assert_called_once()
assert not update.builds[0].signed

@patch('bodhi.server.models.Update.untag')
@patch('bodhi.server.tasks.handle_side_and_related_tags_task.delay')
@patch('bodhi.server.tasks.check_signed_builds.buildsys')
@patch('bodhi.server.tasks.check_signed_builds.log.debug')
def test_check_signed_builds_stuck_Update_fromtag_with_signed_build(self, debug, buildsys,
tag, untag):
"""
The side-tag update was probably ejected from a compose and is stuck.
"""
update = models.Update.query.first()
update.from_tag = 'f17-build-side-1111'
assert update.builds[0].signed

self.db.commit()

listTags = [
{'arches': 'i386 x86_64 ppc ppc64', 'id': 1111, 'locked': False,
'name': 'f17-build-side-1111', 'perm': None, 'perm_id': None,
'extra': {'sidetag_user': 'guest', 'sidetag': True}},
{'arches': None, 'id': 10, 'locked': True,
'name': 'f17-updates-testing', 'perm': None, 'perm_id': None},]

buildsys.get_session.return_value.listTags.return_value = listTags
check_signed_builds_main()

buildsys.get_session.assert_called_once()
calls = [call('bodhi-2.0-1.fc17 already marked as signed'),
call(f'Resubmitting {update.alias} to testing')]
debug.assert_has_calls(calls)
untag.assert_called_once()
tag.assert_called_with(builds=['bodhi-2.0-1.fc17'],
pending_signing_tag='f17-updates-signing-pending',
from_tag='f17-build-side-1111',
candidate_tag='f17-updates-candidate')
assert not update.builds[0].signed

@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/PR5850.bug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The task responsible for unstuck updates ejected from the push has been fixed for correct handling side-tag updates

0 comments on commit a305571

Please sign in to comment.