Skip to content

Commit ab40772

Browse files
authored
Merge pull request kubernetes#88911 from tkashem/readyz-shutdown
/readyz should start returning failure on shutdown initiation
2 parents f52cbea + 4134494 commit ab40772

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,14 @@ func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) error {
318318

319319
go func() {
320320
defer close(delayedStopCh)
321+
321322
<-stopCh
322323

324+
// As soon as shutdown is initiated, /readyz should start returning failure.
325+
// This gives the load balancer a window defined by ShutdownDelayDuration to detect that /readyz is red
326+
// and stop sending traffic to this server.
327+
close(s.readinessStopCh)
328+
323329
time.Sleep(s.ShutdownDelayDuration)
324330
}()
325331

@@ -379,7 +385,6 @@ func (s preparedGenericAPIServer) NonBlockingRun(stopCh <-chan struct{}) error {
379385
// ensure cleanup.
380386
go func() {
381387
<-stopCh
382-
close(s.readinessStopCh)
383388
close(internalStopCh)
384389
if stoppedCh != nil {
385390
<-stoppedCh

0 commit comments

Comments
 (0)