Skip to content

Commit

Permalink
Start web hooks first
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Oct 11, 2021
1 parent e1880f5 commit cc6d878
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/manager/internal.go
Expand Up @@ -476,6 +476,11 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) {
go cm.serveHealthProbes()
}

// Webhooks MUST start before any cache is populated, otherwise there is a race condition
// between conversion webhooks and the cache sync (usually initial list) which causes the webhooks
// to never start because no cache can be populated.
cm.startWebhookRunnables()

go cm.startNonLeaderElectionRunnables()

go func() {
Expand Down Expand Up @@ -573,13 +578,10 @@ func (cm *controllerManager) waitForRunnableToEnd(shutdownCancel context.CancelF
return nil
}

func (cm *controllerManager) startNonLeaderElectionRunnables() {
func (cm *controllerManager) startWebhookRunnables() {
cm.mu.Lock()
defer cm.mu.Unlock()

// First start any webhook servers, which includes conversion, validation, and defaulting
// webhooks that are registered.
//
// WARNING: Webhooks MUST start before any cache is populated, otherwise there is a race condition
// between conversion webhooks and the cache sync (usually initial list) which causes the webhooks
// to never start because no cache can be populated.
Expand All @@ -588,6 +590,11 @@ func (cm *controllerManager) startNonLeaderElectionRunnables() {
cm.startRunnable(c)
}
}
}

func (cm *controllerManager) startNonLeaderElectionRunnables() {
cm.mu.Lock()
defer cm.mu.Unlock()

// Start and wait for caches.
cm.waitForCache(cm.internalCtx)
Expand Down

0 comments on commit cc6d878

Please sign in to comment.