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

Prevent race condition waiting for condition #326

Merged
merged 1 commit into from
Aug 30, 2023
Merged

Conversation

pablochacin
Copy link
Collaborator

@pablochacin pablochacin commented Aug 29, 2023

Description

Apply a get-then-watch strategy when waiting for conditions in a Pod, to avoid situations when the watch misses the change that made the condition true.

Fixes #280

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make test) and all tests pass.
  • I have run relevant e2e test locally (make e2e-xxx for agent, disruptors, kubernetes or cluster related changes)
  • Any dependent changes have been merged and published in downstream modules

Signed-off-by: Pablo Chacin <pablochacin@gmail.com>
@pablochacin pablochacin changed the title WIP: Prevent race condition in test Prevent race condition in test Aug 29, 2023
@pablochacin pablochacin marked this pull request as ready for review August 29, 2023 15:15
@pablochacin pablochacin changed the title Prevent race condition in test Prevent race condition waiting for condition Aug 29, 2023
Copy link
Collaborator

@roobre roobre left a comment

Choose a reason for hiding this comment

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

Looking good so far. Should we add a few integration tests for this logic?

I would love to have a couple tests checking that the function works whether when this function is called after or before the state is changed to "Running".

@pablochacin
Copy link
Collaborator Author

I would love to have a couple tests checking that the function works whether when this function is called after or before the state is changed to "Running".

That is what the TestPods_Wait tests do.

@roobre
Copy link
Collaborator

roobre commented Aug 29, 2023

That is what the TestPods_Wait tests do.

🤦🏻‍♀️ Should have checked that before saying anything

@pablochacin pablochacin merged commit 6496cf1 into main Aug 30, 2023
7 checks passed
@pablochacin pablochacin deleted the fix-flaky-test branch August 30, 2023 07:04
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.

TestPods_AddEphemeralContainer became flaky
2 participants