-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[VPA] Use factory start to fill caches instead of separate informers #8259
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
Conversation
Signed-off-by: Yuriy Losev <[email protected]>
Hi @yalosev. 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. |
Signed-off-by: Yuriy Losev <[email protected]>
/ok-to-test |
Thank you! |
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 for this. some comments from me
if !synced { | ||
klog.V(0).InfoS("Initial sync failed", "kind", informerType) |
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.
When informer sync fails, it means that the controller doesn't have a complete view of the cluster state which could lead to incorrect behavior. So we should:
Use error level logging instead of info such as
klog.ErrorS(nil, "Could not sync cache for "+string(kind))
and exit when sync fails to prevent operating with incomplete state.
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.
This is true for all components code.
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.
Totally agree with you. Fixed.
It was just a copypaste from the current code.
I thought it was weird, but maybe there was some idea behind it.
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.
Yeah not sure why some components were treated this issue differently. anyway, look good now :)
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 should have commented before this was merged, but this does change the behaviour of the app.
If someone had previously restricted the VPA to only resources they care about (for example, may be they denied it access to CronJobs) it (I think) wouldn't have failed to start, but now it will.
Is that enough of a concern to maintain the backwards compatibility?
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 behavior was inconsistent to begin with actually:
https://github.com/kubernetes/autoscaler/pull/8259/files#diff-b234b6b39662bad81ddcb1d9cbc8be663d9984681045f370b7223f410e99c529L100
And
https://github.com/kubernetes/autoscaler/pull/8259/files#diff-b5382ad2d65ec680068c8afdce88601839c9322aa988378022a974db5acc9afdL144
So the idea is to avoid incorrect behavior of the VPA ( and it doesn't change the current behavior )
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.
Oh interesting, right, it seems fine to leave as-is then.
defer close(stopCh) | ||
factory.Start(stopCh) | ||
informerMap := factory.WaitForCacheSync(stopCh) | ||
for informerType, synced := range informerMap { |
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.
For better readability, let's keep consistent variable naming:
for kind, informer := range informersMap {
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.
This is true for all components code.
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.
done
Signed-off-by: Yuriy Losev <[email protected]>
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 for this!
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: omerap12, yalosev 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 |
/label tide/merge-method-squash |
What type of PR is this?
/kind bug
What this PR does / why we need it:
VPA controllers initialize a few informers, but the informers in
targetSelectorFetcher
andcontrollerFetcher
are duplicated. If we start them one by one, it leads to a warning message because the caches are already synchronized.We can use the factory (it was made for this purpose) that was used to create these informers to start them and wait for all caches to sync.
Then caches will be populated without any warning messages.
Potentially, we could start the factory elsewhere, for example inside the
RunOnce
function of the updater.However, that would move it too far from the initialization logic, which might lead to bugs.
So I decided to place the factory start function closer to the
NewSharedInformerFactory
call, right after all informers for this factory are initialized.Which issue(s) this PR fixes:
Fixes #8256
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: