@@ -459,7 +459,17 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) {
459
459
}
460
460
}
461
461
462
- // First start any webhook servers, which includes conversion, validation, and defaulting
462
+ // First start any internal HTTP servers, which includes health probes, metrics and profiling if enabled.
463
+ //
464
+ // WARNING: Internal HTTP servers MUST start before any cache is populated, otherwise it would block
465
+ // conversion webhooks to be ready for serving which make the cache never get ready.
466
+ if err := cm .runnables .HTTPServers .Start (cm .internalCtx ); err != nil {
467
+ if err != nil {
468
+ return fmt .Errorf ("failed to start HTTP servers: %w" , err )
469
+ }
470
+ }
471
+
472
+ // Start any webhook servers, which includes conversion, validation, and defaulting
463
473
// webhooks that are registered.
464
474
//
465
475
// WARNING: Webhooks MUST start before any cache is populated, otherwise there is a race condition
@@ -591,10 +601,13 @@ func (cm *controllerManager) engageStopProcedure(stopComplete <-chan struct{}) e
591
601
cm .logger .Info ("Stopping and waiting for caches" )
592
602
cm .runnables .Caches .StopAndWait (cm .shutdownCtx )
593
603
594
- // Webhooks should come last, as they might be still serving some requests.
604
+ // Webhooks and internal HTTP servers should come last, as they might be still serving some requests.
595
605
cm .logger .Info ("Stopping and waiting for webhooks" )
596
606
cm .runnables .Webhooks .StopAndWait (cm .shutdownCtx )
597
607
608
+ cm .logger .Info ("Stopping and waiting for HTTP servers" )
609
+ cm .runnables .HTTPServers .StopAndWait (cm .shutdownCtx )
610
+
598
611
// Proceed to close the manager and overall shutdown context.
599
612
cm .logger .Info ("Wait completed, proceeding to shutdown the manager" )
600
613
shutdownCancel ()
0 commit comments