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

Wait for updated cache when patching status #245

Merged
merged 2 commits into from
Aug 16, 2023

Conversation

slintes
Copy link
Member

@slintes slintes commented Aug 14, 2023

Add a wait poll after status patch to ensure that the cache is updated before the next reconcile. This will prevent making incorrect decisions based on stale status data.

ECOPROJECT-1530

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 14, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 14, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: slintes

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@slintes
Copy link
Member Author

slintes commented Aug 14, 2023

/test 4.14-openshift-e2e

2 similar comments
@slintes
Copy link
Member Author

slintes commented Aug 14, 2023

/test 4.14-openshift-e2e

@slintes
Copy link
Member Author

slintes commented Aug 15, 2023

/test 4.14-openshift-e2e

@slintes
Copy link
Member Author

slintes commented Aug 15, 2023

/test 4.14-openshift-e2e

@slintes
Copy link
Member Author

slintes commented Aug 15, 2023

/test 4.14-openshift-e2e

Add a wait poll after status patch to ensure that the cache is updated
before the next reconcile. This will prevent making incorrect decisions
based on stale status data.

Signed-off-by: Marc Sluiter <msluiter@redhat.com>
@slintes
Copy link
Member Author

slintes commented Aug 15, 2023

/test 4.14-openshift-e2e

// nothing we can do anymore
return true, nil
}
return false, nil
Copy link
Member

Choose a reason for hiding this comment

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

Return an error?
We never return an error in these lines..

Copy link
Member Author

Choose a reason for hiding this comment

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

why should I return an error here? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

func(ctx context.Context) (bool, error) is expecting an error as the last argument that the function returns, and we haven't returned any error here. I think it would be clearer to not return an error at all and return only a bool or return at least once an error. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

the function signature is fixed, it's an argument to wait.Poll()

Copy link
Member

Choose a reason for hiding this comment

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

Oho, I didn't notice that it's an argument to wait.Poll()

@razo7 razo7 marked this pull request as ready for review August 16, 2023 10:09
Signed-off-by: Marc Sluiter <msluiter@redhat.com>
@slintes
Copy link
Member Author

slintes commented Aug 16, 2023

/override ci/prow/4.12-openshift-e2e

actual e2e succeeded, just some cleanup failed

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 16, 2023

@slintes: Overrode contexts on behalf of slintes: ci/prow/4.12-openshift-e2e

In response to this:

/override ci/prow/4.12-openshift-e2e

actual e2e succeeded, just some cleanup failed

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@slintes
Copy link
Member Author

slintes commented Aug 16, 2023

/override e2e-k8s

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 16, 2023

@slintes: Overrode contexts on behalf of slintes: e2e-k8s

In response to this:

/override e2e-k8s

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

// and making wrong decisions based on it. The chance to run into this is very low, because we use RequeueAfter
// with a minimum delay of 1 second everywhere instead of Requeue: true, but this needs to be fixed because
// it bypasses the controller's rate limiter!
err := wait.PollWithContext(ctx, 200*time.Millisecond, 5*time.Second, func(ctx context.Context) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

NIT: I think I have noticed that wait.PollWithContext is deprecated and wait.PollUntilContextTimeout is advised to be used instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see that in the apimachinery version I use, but I will keep an eye on it when updating dependencies

@razo7
Copy link
Member

razo7 commented Aug 16, 2023

/lgtm
Left small nit, feel free to unhold if you prefer to ignore it
/hold

@slintes
Copy link
Member Author

slintes commented Aug 16, 2023

/hold cancel

@openshift-merge-robot openshift-merge-robot merged commit 35a85c5 into medik8s:main Aug 16, 2023
19 of 20 checks passed
@slintes slintes deleted the fix-potential-cache-issue branch August 25, 2023 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants