From 074d0f9ff25573e369a7b725869f263e9f98ff61 Mon Sep 17 00:00:00 2001 From: du Date: Wed, 15 Nov 2023 18:47:52 +0800 Subject: [PATCH] add comment on sleep during graceful shutdown --- pkg/signals/shutdown.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/signals/shutdown.go b/pkg/signals/shutdown.go index 478576e89..2d8da7bcd 100644 --- a/pkg/signals/shutdown.go +++ b/pkg/signals/shutdown.go @@ -48,7 +48,8 @@ func (s *Shutdown) Graceful(stopCh <-chan struct{}, httpServer *http.Server, htt s.logger.Info("Shutting down HTTP/HTTPS server", zap.Duration("timeout", s.serverShutdownTimeout)) - // wait for Kubernetes readiness probe to remove this instance from the load balancer + // There could be a period where a terminating pod may still receive requests. Implementing a brief wait can mitigate this. + // See: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination // the readiness check interval must be lower than the timeout if viper.GetString("level") != "debug" { time.Sleep(3 * time.Second)