Tolerate missing config ConfigMaps at webhook startup - #16686
Tolerate missing config ConfigMaps at webhook startup#16686rishabhsvats wants to merge 2 commits into
Conversation
The config Store registers its ConfigMaps with the InformedWatcher using plain Watch(), so the watcher fatals at startup if config-defaults, config-features, or config-autoscaler is absent. On a cold start this deadlocks against the config validating webhook (failurePolicy: Fail), which cannot admit the ConfigMaps while the webhook itself is down. Override Store.WatchConfigs to use WatchWithDefault when the watcher is a DefaultingWatcher, registering an empty default per ConfigMap so startup no longer fails. Real ConfigMap values are observed as soon as they appear. Fixes knative#16658 Signed-off-by: Rishabh Singh <rishabhsvats@gmail.com>
|
|
|
Welcome @rishabhsvats! It looks like this is your first PR to knative/serving 🎉 |
|
Hi @rishabhsvats. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/ok-to-test |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16686 +/- ##
==========================================
+ Coverage 80.29% 80.33% +0.04%
==========================================
Files 217 217
Lines 13560 13564 +4
==========================================
+ Hits 10888 10897 +9
+ Misses 2309 2306 -3
+ Partials 363 361 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| // This prevents Start() from failing if ConfigMaps don't exist | ||
| for name := range configConstructors { | ||
| dw.WatchWithDefault(corev1.ConfigMap{ | ||
| ObjectMeta: metav1.ObjectMeta{Name: name}, |
There was a problem hiding this comment.
It seems that the watcher wouldn't be executed due to missing Namespace: system.Namespace(). Could be verified by adding unit tests to cover chhanges.
There was a problem hiding this comment.
Nit 1: missing namespace
Nit 2: no test coverage for the changed default behavior
I'm concerned that the change is not scoped to webhook only, as the store impl is used in revision controller as well. And inherently revision controller might be explicitly relaying on rejecting early mechanism not to start on missing config.
**Webhook-specific scoping:** - Renamed WatchConfigs -> WatchConfigsWithDefaults - Revision controller continues using WatchConfigs (fail-fast behavior) **Fixes:** - Nit 1: Add namespace parameter, pass system.Namespace() - Nit 2: Add unit tests for the new default configuration watcher behavior. The tests verify that all required ConfigMaps are registered with the watcher, the correct namespace is used, default configuration updates the Store through the registered callbacks, real ConfigMaps replace the defaults, and watchers that do not support defaulting continue to use the existing Watch behavior. Signed-off-by: Rishabh Singh <rishabhsvats@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rishabhsvats The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Nit 1 (missing namespace): Added namespace parameter to WatchConfigsWithDefaults and passing system.Namespace() from webhook. Nit 2 (no test coverage): Added 5 tests covering tests to verify that all required ConfigMaps are registered with the watcher, the correct namespace is used, default configuration updates the Store through the registered callbacks, real ConfigMaps replace the defaults, and watchers that do not support defaulting continue to use the existing Watch behavior. This change is now webhook specific. Created new method WatchConfigsWithDefaults used only by webhook controllers. Revision controller continues using existing behavior. |
Fixes #16658
The config Store registers its ConfigMaps with the InformedWatcher using plain Watch(), so the watcher fatals at startup if config-defaults, config-features, or config-autoscaler is absent. On a cold start this deadlocks against the config validating webhook (failurePolicy: Fail), which cannot admit the ConfigMaps while the webhook itself is down.
Proposed Changes
Override
Store.WatchConfigsto useWatchWithDefaultwhen the watcher implementsDefaultingWatcher, registering a synthetic empty default for each ConfigMap.The InformedWatcher then treats a missing ConfigMap as "use the default" instead of failing, so the webhook boots on built-in defaults and can then admit the real ConfigMaps.
Real values are picked up via
OnConfigChangedas soon as the ConfigMaps appear. Watchers that aren'tDefaultingWatcherfall back to the previousWatch()behaviour.Release Note