@@ -591,16 +591,47 @@ func (cm *controllerManager) startNonLeaderElectionRunnables() {
591
591
cm .mu .Lock ()
592
592
defer cm .mu .Unlock ()
593
593
594
+ // First start any webhook servers, which includes conversion, validation, and defaulting
595
+ // webhooks that are registered.
596
+ //
597
+ // WARNING: Webhooks MUST start before any cache is populated, otherwise there is a race condition
598
+ // between conversion webhooks and the cache sync (usually initial list) which causes the webhooks
599
+ // to never start because no cache can be populated.
600
+ for _ , c := range cm .nonLeaderElectionRunnables {
601
+ if _ , ok := c .(* webhook.Server ); ok {
602
+ cm .startRunnable (c )
603
+ }
604
+ }
605
+
606
+ // Start and wait for caches.
594
607
cm .waitForCache (cm .internalCtx )
595
608
596
609
// Start the non-leaderelection Runnables after the cache has synced
597
610
for _ , c := range cm .nonLeaderElectionRunnables {
611
+ if _ , ok := c .(* webhook.Server ); ok {
612
+ continue
613
+ }
614
+
598
615
// Controllers block, but we want to return an error if any have an error starting.
599
616
// Write any Start errors to a channel so we can return them
600
617
cm .startRunnable (c )
601
618
}
602
619
}
603
620
621
+ //func (cm *controllerManager) startNonLeaderElectionRunnables() {
622
+ // cm.mu.Lock()
623
+ // defer cm.mu.Unlock()
624
+ //
625
+ // cm.waitForCache(cm.internalCtx)
626
+ //
627
+ // // Start the non-leaderelection Runnables after the cache has synced
628
+ // for _, c := range cm.nonLeaderElectionRunnables {
629
+ // // Controllers block, but we want to return an error if any have an error starting.
630
+ // // Write any Start errors to a channel so we can return them
631
+ // cm.startRunnable(c)
632
+ // }
633
+ //}
634
+
604
635
func (cm * controllerManager ) startLeaderElectionRunnables () {
605
636
cm .mu .Lock ()
606
637
defer cm .mu .Unlock ()
0 commit comments