-
Notifications
You must be signed in to change notification settings - Fork 1.4k
✨ Introduce & use wait for cache utils #12957
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
✨ Introduce & use wait for cache utils #12957
Conversation
0395f91 to
f95110e
Compare
f94f7dd to
fd6def0
Compare
|
/assign @fabriziopandini @chrischdi |
fd6def0 to
9c4e58b
Compare
|
/test pull-cluster-api-e2e-main-gke |
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.
thanks!
/lgtm
|
LGTM label has been added. Git tree hash: 2b7c1e59dd5aa9241ac7a5651d97e04000be3f52
|
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.
Nice to have this util!
Just a few nits from my side
| // WaitForCacheToBeUpToDate waits until the cache is up-to-date in the sense of that the cache contains | ||
| // all passed in objects with at least the passed in resourceVersion. | ||
| // This is done by retrieving objects from the cache via the client and then comparing resourceVersions. | ||
| // Note: This func will update the passed in objects while polling. |
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.
Is there a specific reason for this behaviour?
I'm a little bit worried that this could bring in some unexpected change that could invalidate assumptions on the object state that the following code relies on
(I also saw in some places you are deep copying the object before calling this method)
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 use DeepCopy only in once place and that is in the topology controller for cluster as it is extremely hard on pre-existing code like that to figure out what changes if I change that.
In general I think this is the right thing to do. Usually the code is used like this
- obj in state 1
- ssa.Patch(obj)
- afterwards => obj is already updated to state 2 (the response from the apiserver)
- WaitForCacheToBeUpToDate
- afterwards => obj is updated to state 3 which has resourceVersion >= of state 2
If I don't do this any subsequent code might be running with a stale object and I don't think that's a good idea.
If the feature will be embedded in the CR client we would get the same behavior as there is no reason to knowingly keep using a stale object
tl;dr this matches the behavior of any client write call that we do immediately before calling this func
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.
Ok, I see the point in aligning to the future CR behaviour, we can always deep copy when calling the func
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. I think the one case where we deepcopy will also remain the exception. Going forward we will just not deepcopy.
It's just hard to figure out what effects it might have if I change it considering all the code that is running after we update the cluster
|
Thx everyone, PTAL :) |
|
Looks good! /lgtm |
|
LGTM label has been added. Git tree hash: a2087241fcfdc6c08c024d290c300e90cdf6e633
|
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini 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 |
15e510f to
e379253
Compare
|
/test pull-cluster-api-e2e-main-gke |
|
Had to push another very small change, forgot to adjust the expected error message in one unit test |
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
|
LGTM label has been added. Git tree hash: d059807b84ee471f52f24833dc2f41ebfe99e841
|
|
Oops. :) /lgtm |
e379253 to
f897573
Compare
|
And of course a merge conflict, rebased :) /test pull-cluster-api-e2e-main-gke |
|
/lgtm |
|
LGTM label has been added. Git tree hash: 3ad356412a4a183f8e2f3694ef4fc3761a0279af
|
|
/lgtm |
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Part of #12291