-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better gating status #4221
Better gating status #4221
Conversation
56072c3
to
0b1a3c3
Compare
edit: ok, cleaned up now. For some reason setting |
0b1a3c3
to
e90270c
Compare
Ping? Anybody? I would like to help maintainers avoid unnecessary distress here :D |
+1 I think it's a good idea. |
e90270c
to
7dfd24f
Compare
So how about this version? I think it's even simpler, and it manages to avoid some duplication with the old I did go and look at the greenwave side code and I think the basic idea here is safe. I don't think it should be possible for this logic to be wrong. You can see the main relevant part of the greenwave code here - it seems pretty clear-cut to me. I also checked that it's not possible for Greenwave to produce a decision with |
bodhi/server/models.py
Outdated
|
||
return unsatisfied_requirements | ||
return TestGatingStatus.failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it is worth optimizing for this case, but it could stop fetching any next "greenwave_request_batches" when there is an unsatisfied requirement (that is not test-result-missing
when last modification is under 2hrs).
I'm assuming that it won't happen too often so it is fine as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I see what you mean. The trade-off there is that we'd probably have to put back the near-duplication I took out in this version, unless I can think of a clever way to do it. I can think about it a bit.
+1 Looks good, much easier to read. |
bodhi/server/models.py
Outdated
@@ -3051,7 +3075,8 @@ def waive_test_results(self, username, comment=None, tests=None): | |||
# Ensure we can always iterate over tests | |||
tests = tests or [] | |||
|
|||
for requirement in self._unsatisfied_requirements: | |||
# these are the unsatisfied requirements | |||
for requirement in self._greenwave_requirements[1]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simple class for the requirement would avoid some mistakes and need for such explanation comments.
class GreenwaveRequirements:
def __init__(self):
self.satisfied = []
self.unsatisfied = []
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, if we want to do that we could just use collections.namedtuple
. I thought about it but it seemed a bit excessive for just this one case. Can change it if you like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, sounds good, better than having to use an index. 👍
7dfd24f
to
9f07dc9
Compare
So I updated to a version which does short-circuit later batches if a definite 'failure' case is encountered in an earlier query batch. It does make things rather more complicated, though, so for the record, if we prefer the simpler but slightly less efficient code, the commit with that version is |
ping? I don't think the test failures here are to do with the PR, btw. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the test failures are unrelated, but the flake8 test fails:
./bodhi/tests/server/tasks/test_check_policies.py:130:101: E501 line too long (101 > 100 characters)
Can you also add a news fragment in /news ?
Signed-off-by: Adam Williamson <awilliam@redhat.com>
9f07dc9
to
a856f0c
Compare
Looks good, however I'd like to see some test results before approving. |
Are you waiting for something from me here? |
No, I'm waiting for some admin to manually merge #4226 (or for some admin to give me admin access to Bodhi) so that required tests can pass and mergify can auto merge this PR. Sorry, but I can't override failing tests at the moment. |
@Zlopez this is the other ticket! |
@AdamSaleh The tests are failing on Fedora Messaging consumer container not ready. I see the same issue happened in #4244, but I'm not sure if this is just some temporary issue that will go away next time I try to run the tests. Could this be just that the rabbitmq container takes too long to start and this is why we get timeout? |
Because the
@AdamWill Could you address these issues in the PR? |
Thanks, will do. |
On the normal path of creating an update - where it is created and immediately submitted to updates-testing - we're setting the gating status twice. We call `set_request`, which calls `update_test_gating_status()` if the request is updates-testing and gating is required, and then almost immediately afterwards, we straight up set the status to 'waiting'. That doesn't make much sense. This changes things so that the `new()` method doesn't hard set the status to 'waiting' if it's calling `set_request` and the request is to updates-testing, as is usually the case. Signed-off-by: Adam Williamson <awilliam@redhat.com>
Signed-off-by: Adam Williamson <awilliam@redhat.com>
556e152
to
469cba0
Compare
…ra#4219) This is part of addressing fedora-infra#4219. Currently we always count the gating status as failed if requirements are unsatisfied. However, it's usual for test results to not be present yet for a little while after the update is created or edited. Ideally we would have a mechanism for knowing for sure whether the tests in question are pending, but we don't, so let's use a dumb rule instead: if there are no failures (only missing results), and it's less than two hours since the update was last modified, we'll return 'waiting' as the status. After two hours, maybe the tests actually didn't get scheduled or the policy is wrong, so we'll return 'failed'. This also simplifies the logic used to decide the status, and reduces code duplication. We can determine the status using only the number of satisfied and unsatisfied requirements: if there are none of either it is ignored, if there are satisfied requirements and no unsatisfied requirements it is passed, otherwise it is failed or waiting. As part of this we change the mock greenwave responses used in a lot of other tests to use test-result-failed not -missing, because they currently use -missing but expect the gating status to be 'failed', which it no longer always will be. We also have to make the mock greenwave responses used in tests that hit this code a bit more realistic - they have to always include the satisfied and unsatisfied requirement lists. Note I've checked greenwave code and it does always include these in a successful query response. Signed-off-by: Adam Williamson <awilliam@redhat.com>
Signed-off-by: Adam Williamson <awilliam@redhat.com>
469cba0
to
34c55c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the tests locally and everything is now passing. The code also looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it was stuck waiting for me... sorry
Oof, is the merge commit really necessary? Would you like me to rebase it? |
mergify should handle it automatically. The PR got stuck again because the f33-diff-cover test has failed, but I think it's unrelated to the changes. |
Signed-off-by: Adam Williamson <awilliam@redhat.com>
This is an attempt to improve some issues around gating status for critical path updates, as reported in #4219 . Combined, these patches should mean we don't pingpong the state, and for the first two hours after an update is created or edited, the state will be 'waiting' if there are missing results but no failures.