Skip to content

Commit

Permalink
Let koji handle the deletion of side tags.
Browse files Browse the repository at this point in the history
Fixes #4055.

Signed-off-by: Clement Verna <[email protected]>
  • Loading branch information
cverna authored and mergify[bot] committed Jun 18, 2020
1 parent 23daf7e commit 519c491
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 22 deletions.
18 changes: 0 additions & 18 deletions bodhi/server/buildsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def clear(cls):
cls.__rpms__ = []
cls.__tags__ = []
cls.__side_tags__ = list(cls._side_tag_data)
cls.__removed_side_tags__ = []

def multiCall(self):
"""Emulate Koji's multiCall."""
Expand Down Expand Up @@ -541,23 +540,6 @@ def deleteTag(self, tagid: typing.Union[str, int]):
else:
del self.__tags__[tagid]

def removeSideTag(self, side_tag):
"""Emulate side-tag and build target deletion."""
if isinstance(side_tag, int):
what = 'id'
elif isinstance(side_tag, str):
what = 'name'
else:
raise TypeError(f'sidetag: {side_tag!r}')

matching_tags = [t for t in self.__side_tags__ if t[what] == side_tag]

if not matching_tags:
raise koji.GenericError(f"Not a sidetag: {side_tag}")

self.__side_tags__.remove(matching_tags[0])
self.__removed_side_tags__.append(matching_tags[0])

def getRPMHeaders(self, rpmID: str,
headers: typing.Any) -> typing.Union[typing.Mapping[str, str], None]:
"""
Expand Down
4 changes: 2 additions & 2 deletions bodhi/server/tasks/approve_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def approve_update(update: Update, db: Session):
update.date_stable = update.date_pushed = func.current_timestamp()
update.comment(db, "This update has been submitted for stable by bodhi",
author=u'bodhi')
db.commit()
# Multi build update
if update.from_tag:
# Merging the side tag should happen here
Expand All @@ -136,8 +137,7 @@ def approve_update(update: Update, db: Session):
koji = buildsys.get_session()
koji.deleteTag(pending_signing_tag)
koji.deleteTag(testing_tag)
# Removes the tag and the build target from koji.
koji.removeSideTag(update.from_tag)

else:
# Single build update
update.remove_tag(update.release.pending_testing_tag)
Expand Down
1 change: 0 additions & 1 deletion bodhi/server/tasks/handle_side_and_related_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def main(builds: typing.List[str],
# side tag into the release pending_signing and candidate tag.
# We can remove the side tag.
tags.append(candidate_tag)
koji.removeSideTag(from_tag)

koji.multicall = True
for b in builds:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def test_side_tag_composed_by_bodhi(self):
koji = buildsys.get_session()
assert ('f17-updates-signing-pending', 'bodhi-2.0-1.fc17') in koji.__added__
assert ('f17-updates-candidate', 'bodhi-2.0-1.fc17') in koji.__added__
assert {'id': 1234, 'name': 'f17-build-side-1234'} in koji.__removed_side_tags__

def test_side_tag_not_composed_by_bodhi(self):
u = self.db.query(models.Update).first()
Expand All @@ -56,6 +55,7 @@ def test_side_tag_not_composed_by_bodhi(self):
def test_side_tag_raise_exception(self, caplog):
update = self.db.query(models.Update).first()
builds = [b.nvr for b in update.builds]
update.release.pending_signing_tag = None
handle_srtags_main(builds, update.release.pending_signing_tag, None, None,
update.release.candidate_tag)
assert "There was an error handling side-tags updates" in caplog.messages
1 change: 1 addition & 0 deletions news/4055.bug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Let koji handle the side tag deletion

0 comments on commit 519c491

Please sign in to comment.