From 1145582de367b9aa4072e631845ce3abc37b8540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Thu, 12 May 2022 17:22:36 +0200 Subject: [PATCH] Diagram for graceful shutdown --- .../apiserver/pkg/server/genericapiserver.go | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go index 1deb78252d8..2377fb8fec0 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go +++ b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go @@ -421,6 +421,33 @@ func (s *GenericAPIServer) PrepareRun() preparedGenericAPIServer { // Run spawns the secure http server. It only returns if stopCh is closed // or the secure port cannot be listened on initially. +// This is the diagram of what channels/signals are dependent on each other: +// +// stopCh +// | +// --------------------------------------------------------- +// | | +// ShutdownInitiated (shutdownInitiatedCh) | +// | | +// (ShutdownDelayDuration) (PreShutdownHooks) +// | | +// AfterShutdownDelayDuration (delayedStopCh) preShutdownHooksHasStoppedCh +// | | +// |---------------------------------- | +// | | | +// | (HandlerChainWaitGroup::Wait) | +// | | | +// | InFlightRequestsDrained (drainedCh) | +// | | | +// [without ShutdownSendRetryAfter] [with ShutdownSendRetryAfter] | +// | | | +// --------------------------------------------------------- +// | +// stopHttpServerCh +// | +// listenerStoppedCh +// | +// HTTPServerStoppedListening (httpServerStoppedListeningCh) func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) error { delayedStopCh := s.lifecycleSignals.AfterShutdownDelayDuration shutdownInitiatedCh := s.lifecycleSignals.ShutdownInitiated