Skip to content
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

Merged
merged 5 commits into from
Sep 8, 2021
Merged

Conversation

AdamWill
Copy link
Contributor

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.

@AdamWill AdamWill requested a review from a team as a code owner May 18, 2021 22:12
@AdamWill AdamWill force-pushed the better-gating-status branch 4 times, most recently from 56072c3 to 0b1a3c3 Compare May 19, 2021 02:41
@AdamWill
Copy link
Contributor Author

AdamWill commented May 19, 2021

edit: ok, cleaned up now. For some reason setting update.date_modified in the test just doesn't work, but fortunately setting update.date_submitted does work and does the same job, so hey. Let's go with that. This now passes all tests locally; the failures are due to a version mismatch in the CI environment and nothing to do with this PR, I don't think.

@AdamWill AdamWill force-pushed the better-gating-status branch from 0b1a3c3 to e90270c Compare May 19, 2021 06:51
@AdamWill
Copy link
Contributor Author

Ping? Anybody? I would like to help maintainers avoid unnecessary distress here :D

bodhi/server/models.py Outdated Show resolved Hide resolved
@hluk
Copy link
Contributor

hluk commented May 21, 2021

+1 I think it's a good idea.

@AdamWill AdamWill force-pushed the better-gating-status branch from e90270c to 7dfd24f Compare May 21, 2021 20:57
@AdamWill
Copy link
Contributor Author

So how about this version? I think it's even simpler, and it manages to avoid some duplication with the old _unsatisfied_requirements property (now renamed _greenwave_requirements). I also like that the docstring exactly matches the code.

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 policies_satisfied but without the requirement lists - they are all produced together in a single statement. The only time those things are not in the response is on an error path, and we handle error responses differently.


return unsatisfied_requirements
return TestGatingStatus.failed
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@hluk
Copy link
Contributor

hluk commented May 23, 2021

+1 Looks good, much easier to read.

@@ -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]:
Copy link
Contributor

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 = []

Copy link
Contributor Author

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?

Copy link
Contributor

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. 👍

@mattiaverga mattiaverga added this to the 5.7.1 milestone May 25, 2021
@AdamWill AdamWill force-pushed the better-gating-status branch from 7dfd24f to 9f07dc9 Compare May 27, 2021 21:12
@AdamWill
Copy link
Contributor Author

AdamWill commented May 28, 2021

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 7dfd24f282f17774b68f75c5b5b77d91fa1673c6. I can restore the PR to that state (then change it to use a namedtuple) if we prefer it.

@AdamWill
Copy link
Contributor Author

AdamWill commented Jun 1, 2021

ping? I don't think the test failures here are to do with the PR, btw.

Copy link
Contributor

@hluk hluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mattiaverga mattiaverga linked an issue Jun 3, 2021 that may be closed by this pull request
Copy link
Contributor

@mattiaverga mattiaverga left a 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 ?

AdamWill added a commit to AdamWill/bodhi that referenced this pull request Jun 3, 2021
Signed-off-by: Adam Williamson <awilliam@redhat.com>
@AdamWill AdamWill force-pushed the better-gating-status branch from 9f07dc9 to a856f0c Compare June 3, 2021 22:13
@mattiaverga
Copy link
Contributor

Looks good, however I'd like to see some test results before approving.

@mattiaverga mattiaverga self-requested a review June 7, 2021 08:29
@AdamWill
Copy link
Contributor Author

Are you waiting for something from me here?

@mattiaverga
Copy link
Contributor

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.

@mattiaverga mattiaverga dismissed their stale review June 12, 2021 07:01

waiting for tests fix

@lgriffin
Copy link

lgriffin commented Sep 2, 2021

@Zlopez this is the other ticket!

@Zlopez
Copy link
Contributor

Zlopez commented Sep 7, 2021

@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?

@Zlopez
Copy link
Contributor

Zlopez commented Sep 7, 2021

Because the pip-pydocstyle test is failing with container not ready issue. I ran the tests locally for it and found two issues:

bodhi/server/models.py:2218 in private method `_greenwave_requirements_generator`:
        D205: 1 blank line required between summary line and description (found 0)
bodhi/server/models.py:2218 in private method `_greenwave_requirements_generator`:
        D400: First line should end with a period (not 'd')

@AdamWill Could you address these issues in the PR?

@AdamWill
Copy link
Contributor Author

AdamWill commented Sep 7, 2021

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>
AdamWill added a commit to AdamWill/bodhi that referenced this pull request Sep 7, 2021
Signed-off-by: Adam Williamson <awilliam@redhat.com>
@AdamWill AdamWill force-pushed the better-gating-status branch from 556e152 to 469cba0 Compare September 7, 2021 15:39
…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>
@AdamWill AdamWill force-pushed the better-gating-status branch from 469cba0 to 34c55c3 Compare September 7, 2021 15:43
Copy link
Contributor

@Zlopez Zlopez left a 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.

Copy link
Contributor

@mattiaverga mattiaverga left a 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

@AdamWill
Copy link
Contributor Author

AdamWill commented Sep 8, 2021

Oof, is the merge commit really necessary? Would you like me to rebase it?

@mattiaverga
Copy link
Contributor

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.
I'll give it another try.

@mergify mergify bot merged commit 1bce05d into fedora-infra:develop Sep 8, 2021
AdamSaleh pushed a commit that referenced this pull request Sep 9, 2021
Signed-off-by: Adam Williamson <awilliam@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Less scary UI and email rules for gating status changes
5 participants