Skip to content

Commit b6a5752

Browse files
Start web hooks first
1 parent 43ea648 commit b6a5752

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pkg/manager/internal.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,11 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) {
476476
go cm.serveHealthProbes()
477477
}
478478

479+
// Webhooks MUST start before any cache is populated, otherwise there is a race condition
480+
// between conversion webhooks and the cache sync (usually initial list) which causes the webhooks
481+
// to never start because no cache can be populated.
482+
cm.startWebhookRunnables()
483+
479484
go cm.startNonLeaderElectionRunnables()
480485

481486
go func() {
@@ -573,13 +578,10 @@ func (cm *controllerManager) waitForRunnableToEnd(shutdownCancel context.CancelF
573578
return nil
574579
}
575580

576-
func (cm *controllerManager) startNonLeaderElectionRunnables() {
581+
func (cm *controllerManager) startWebhookRunnables() {
577582
cm.mu.Lock()
578583
defer cm.mu.Unlock()
579584

580-
// First start any webhook servers, which includes conversion, validation, and defaulting
581-
// webhooks that are registered.
582-
//
583585
// WARNING: Webhooks MUST start before any cache is populated, otherwise there is a race condition
584586
// between conversion webhooks and the cache sync (usually initial list) which causes the webhooks
585587
// to never start because no cache can be populated.
@@ -588,6 +590,11 @@ func (cm *controllerManager) startNonLeaderElectionRunnables() {
588590
cm.startRunnable(c)
589591
}
590592
}
593+
}
594+
595+
func (cm *controllerManager) startNonLeaderElectionRunnables() {
596+
cm.mu.Lock()
597+
defer cm.mu.Unlock()
591598

592599
// Start and wait for caches.
593600
cm.waitForCache(cm.internalCtx)

0 commit comments

Comments
 (0)