Skip to content

Commit

Permalink
Drop a bogus branch from check_karma_thresholds
Browse files Browse the repository at this point in the history
This has been hanging around for a while, but it's fairly
useless. At some point this is where we were planning to post
the testing_approval_msg message if the update reached the
critpath.min_karma threshold, but that is actually done by
the approve_testing.py script nowadays. All we do here is log a
message, and it's actually a bogus message anyway, because
stable_karma is *not* the manual push threshold. stable_karma
is the autopush threshold; it's really meaningless if autokarma
is not set. So it doesn't make any sense to log this message
when we hit stable_karma but autopush is not set. We should just
do nothing on that path.

Note this slightly changes when we set date_approved, but the
current behaviour around date_approved makes no sense anyway,
so the next commit revamps it entirely to make much more sense.

Signed-off-by: Adam Williamson <[email protected]>
(cherry picked from commit f16c8f9)
  • Loading branch information
AdamWill authored and mergify[bot] committed Oct 5, 2024
1 parent 31fc0cc commit 329f426
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
16 changes: 5 additions & 11 deletions bodhi-server/bodhi/server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3830,22 +3830,16 @@ def check_karma_thresholds(self, db, agent):
text = config.get('disable_automatic_push_to_stable')
self.comment(db, text, author='bodhi')
elif self.stable_karma and self.karma >= self.stable_karma \
and self.release.composed_by_bodhi:
and self.release.composed_by_bodhi and self.autokarma:
if config.get('test_gating.required') and not self.test_gating_passed:
log.info("%s reached stable karma threshold, but does not meet gating "
"requirements", self.alias)
return
self.date_approved = datetime.utcnow()
if self.autokarma:
log.info("Automatically marking %s as stable", self.alias)
self.set_request(db, UpdateRequest.stable, agent)
notifications.publish(update_schemas.UpdateKarmaThresholdV1.from_dict(
dict(update=self, status='stable')))
else:
# Add the stable approval message now
log.info((
"%s update has reached the stable karma threshold and can be pushed to "
"stable now if the maintainer wishes"), self.alias)
log.info("Automatically marking %s as stable", self.alias)
self.set_request(db, UpdateRequest.stable, agent)
notifications.publish(update_schemas.UpdateKarmaThresholdV1.from_dict(
dict(update=self, status='stable')))
elif self.unstable_karma and self.karma <= self.unstable_karma:
log.info("Automatically obsoleting %s (reached unstable karma threshold)", self.alias)
self.obsolete(db)
Expand Down
5 changes: 2 additions & 3 deletions bodhi-server/tests/services/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4890,9 +4890,6 @@ def test_autopush_reached_main(self, autokarma, cbb, critpath, status):
up.status = status
msgs = self._reach_autopush_threshold(up)

# we always set date_approved if release is composed by bodhi
assert bool(up.date_approved) is cbb

if (cbb and autokarma):
# we should have autopushed
assert up.request is UpdateRequest.stable
Expand All @@ -4912,6 +4909,7 @@ def test_autopush_reached_main(self, autokarma, cbb, critpath, status):
{'comment': up['comments'][-2], 'agent': 'bowlofeggs'}
)
]
assert up.date_approved is not None
else:
# we should not
assert up.request is None
Expand All @@ -4922,6 +4920,7 @@ def test_autopush_reached_main(self, autokarma, cbb, critpath, status):
{'comment': up['comments'][-1], 'agent': 'bowlofeggs'}
)
]
assert up.date_approved is None

def test_autopush_reached_obsolete(self):
"""Autopush should not happen if it otherwise would, but the update is obsolete."""
Expand Down

0 comments on commit 329f426

Please sign in to comment.