Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Start web hooks first #1690

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 19 additions & 10 deletions pkg/manager/internal.go
Expand Up @@ -425,11 +425,13 @@ func (cm *controllerManager) serveHealthProbes() {
cm.healthzStarted = true
}()

// Shutdown the server when stop is closed
<-cm.internalProceduresStop
if err := server.Shutdown(cm.shutdownCtx); err != nil {
cm.errChan <- err
}
go func() {
// Shutdown the server when stop is closed
<-cm.internalProceduresStop
if err := server.Shutdown(cm.shutdownCtx); err != nil {
cm.errChan <- err
}
}()
}

func (cm *controllerManager) Start(ctx context.Context) (err error) {
Expand Down Expand Up @@ -473,9 +475,14 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) {

// Serve health probes
if cm.healthProbeListener != nil {
go cm.serveHealthProbes()
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 +580,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()
vincepri marked this conversation as resolved.
Show resolved Hide resolved

// 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 +592,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