-
Notifications
You must be signed in to change notification settings - Fork 41.9k
Add test for replace events in client-go controller #135665
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
base: master
Are you sure you want to change the base?
Conversation
|
Please note that we're already in Test Freeze for the Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Mon Dec 8 15:38:13 UTC 2025. |
|
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: michaelasp The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/cc @serathius |
| updateCh: make(chan bool, 1), | ||
| } | ||
| fifo := NewRealFIFOWithOptions(RealFIFOOptions{ | ||
| KeyFunction: MetaNamespaceKeyFunc, |
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.
Why do we use either DeletionHandlingMetaNamespaceKeyFunc or MetaNamespaceKeyFunc? Could we ensure the whole test using same KeyFunc?
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.
We don't even need to pass the keyfunc to the FIFO, we can use DeletionHandlingMetaNamespaceKeyFunc here but it's not required. I just removed this from being passed to the FIFO.
| } | ||
|
|
||
| select { | ||
| case <-m.updateCh: |
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.
The more "kosher" way to do that would be using sync.Cond. See
kubernetes/staging/src/k8s.io/apiserver/pkg/storage/cacher/progress/watch_progress.go
Lines 62 to 63 in b4980b8
| mux sync.Mutex | |
| cond *sync.Cond |
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 was under the assumption that a cvar was more low level, in our case I'd like to wait on the channel but time out if the context is cancelled. Channels let us do that but a cvar would require a bit more work, right? This is a bit less efficient than a raw cvar but gives us more flexibility on the select. Not too picky either way though, especially for a test.
| expectHistory := []eventRecord{ | ||
| {Action: "add", Key: "default/pod-add"}, | ||
| {Action: "delete", Key: "default/pod-del"}, | ||
| {Action: "update", Key: "default/pod-keep"}, |
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.
Food for thought as a future idea. If replace just just triggered based on watch resynchronization there is technically no reason to trigger update for it if the RV is matching. There is a small change that value was corrupted and we wanted to refresh it in controller, so we might need to design a separate mechanism to detect that, but it would be much cheaper for controllers.
5aa45ec to
ab33a33
Compare
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds additional testing to replace events to ensure that replace events and the underlying store is correct.
Which issue(s) this PR is related to:
KEP: kubernetes/enhancements#5647
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: