Merge pull request #102671 from tkashem/gt-wait

apiserver: close handler chain right after shutdown delay duration
This commit is contained in:
Kubernetes Prow Robot 2021-06-08 10:05:34 -07:00 committed by GitHub
commit b1369fe606
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -351,6 +351,17 @@ func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) error {
return err
}
drainedCh := make(chan struct{})
go func() {
defer close(drainedCh)
// wait for the delayed stopCh before closing the handler chain (it rejects everything after Wait has been called).
<-delayedStopCh
// Wait for all requests to finish, which are bounded by the RequestTimeout variable.
s.HandlerChainWaitGroup.Wait()
}()
<-stopCh
// run shutdown hooks directly. This includes deregistering from the kubernetes endpoint in case of kube-apiserver.
@ -359,14 +370,11 @@ func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) error {
return err
}
// wait for the delayed stopCh before closing the handler chain (it rejects everything after Wait has been called).
<-delayedStopCh
// Wait for all requests in flight to drain, bounded by the RequestTimeout variable.
<-drainedCh
// wait for stoppedCh that is closed when the graceful termination (server.Shutdown) is finished.
<-stoppedCh
// Wait for all requests to finish, which are bounded by the RequestTimeout variable.
s.HandlerChainWaitGroup.Wait()
return nil
}