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
webhook config manager: HasSynced returns true when the manager is synced with existing webhookconfig objects at startup #95783
webhook config manager: HasSynced returns true when the manager is synced with existing webhookconfig objects at startup #95783
Conversation
/triage accepted |
/cc @liggitt |
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/testing/testcase.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/testing/testcase.go
Outdated
Show resolved
Hide resolved
d3a21d8
to
e124292
Compare
e124292
to
e0bc203
Compare
/retest |
staging/src/k8s.io/apiserver/pkg/admission/configuration/mutating_webhook_manager.go
Outdated
Show resolved
Hide resolved
one comment on making this more efficient for servers without any webhooks configured, functionally lgtm otherwise. |
…nced with existing webhookconfig objects at startup
e0bc203
to
37d171e
Compare
/retest |
/lgtm /milestone v1.21 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, pacoxu, roycaihw 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 |
…783-upstream-release-1.19 Automated cherry pick of #95783: webhook config manager: HasSynced returns true when the
…783-upstream-release-1.20 Automated cherry pick of #95783: webhook config manager: HasSynced returns true when the
…783-upstream-release-1.18 Automated cherry pick of #95783: webhook config manager: HasSynced returns true when the
What type of PR is this?
/kind bug
What this PR does / why we need it:
Fix a webhook unittest flake. The test waits for informers to be synced, which guarantees the watch events being sent (the delta fifo queue in the informer has no initial object left), but it doesn't guarantee the webhook configuration manager finishing processing those watch events. Adding a marker to wait for webhook registration, like what we do in the e2e tests.The original race can be reliably reproduced by adding a sleep to the configuration managers.
What happened: webhook config manager
HasSynced()
function returned true if the informer was synced, which could cause requests being allowed without existing webhook configurations being effective at startup.[EDIT] Thanks to @liggitt who pointed out that this isn't just a test issue and suggested the proper fix-- on API server startup, the webhook waits to admit anything until it is synced with existing webhookconfig objects, meaning
validatingWebhookConfigurationManager#HasSynced
andmutatingWebhookConfigurationManager#HasSynced
shouldn't return true until the informer is synced and either has no items orupdateConfiguration()
has completed. This fix guarantees that at no point should requests be allowed into a restarted API server without those previously created webhook configurations being effective.Which issue(s) this PR fixes:
Fixes #94810, #99911, #100070
Does this PR introduce a user-facing change?:
/sig api-machinery
/cc @sttts