-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Fix controller setup in storage version unit testcases #134469
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
|
Welcome @vikasbolla! |
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. |
Hi @vikasbolla. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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: vikasbolla 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 |
/ok-to-test |
controller := NewStorageVersionGC(ctx, clientset, leaseInformer, storageVersionInformer) | ||
informerFactory.Start(ctx.Done()) | ||
// Using this ensure informer caches are fully populated before starting the controller. | ||
if !cache.WaitForCacheSync(ctx.Done(), controller.leasesSynced, controller.storageVersionSynced) { |
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.
Don't think this is strictly necessary. We wait for the sync in controller.Run()
already. https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/storageversiongc/gc_controller.go#L103-L106
+1 to polling instead of checking condition once though.
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 @Jefftree, but controller.Run() is sometimes called even before the informer cache is synced with the object state as controller.Run() is a goroutine, so in that case I think the flakiness is observed
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 PollWithContextTimeout addition should catch those flakes though? Overall I don't have a strong opinion so will defer to the approvers.
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.
actually I have tried only with polling and saw that it alone does not solve issue, when I future investigated got to know that since informer cache never get updates and controller never knows the lease deletion, reconciliation never happens and polling eventually time out
}, | ||
} | ||
// Wait up to 5 seconds, checking every 100ms to ensure controller had a chance to reconcile | ||
err := wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, 5*time.Second, true, func(ctx context.Context) (bool, error) { |
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.
imo it seems to make more sense to wrap the entire reflection check from L126-148 within the wait.PollUntilContextTimeout
. Feels a bit weird that we're just checking the CommonEncodingVersion
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 @Jefftree , made the changes, PTAL
e5918f3
to
caea56f
Compare
/lgtm Thanks! |
LGTM label has been added. Git tree hash: 04d9c8ae9ffb9bec71ba0d1c6880a2321147f0ad
|
/retest |
What type of PR is this?
/kind flake
What this PR does / why we need it:
This PR tries to fix the test flakes
There is an issue during the controller setup in the test file. Controller depends on the informer cache and in this case I can see that the controller call is not controlled based on the informer cache sync, due to which, when the controller is called even before the informer execution, then the worker queue on which the controller is depended on will be empty and the reconciliation logic will timeout.
So added the cache check before calling the controller to make sure the informer cache is properly updated with latest objects state.
Which issue(s) this PR is related to:
Fixes #131745
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: