mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Merge pull request #102671 from tkashem/gt-wait
apiserver: close handler chain right after shutdown delay duration
This commit is contained in:
commit
b1369fe606
@ -351,6 +351,17 @@ func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) error {
|
|||||||
return err
|
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
|
<-stopCh
|
||||||
|
|
||||||
// run shutdown hooks directly. This includes deregistering from the kubernetes endpoint in case of kube-apiserver.
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for the delayed stopCh before closing the handler chain (it rejects everything after Wait has been called).
|
// Wait for all requests in flight to drain, bounded by the RequestTimeout variable.
|
||||||
<-delayedStopCh
|
<-drainedCh
|
||||||
// wait for stoppedCh that is closed when the graceful termination (server.Shutdown) is finished.
|
// wait for stoppedCh that is closed when the graceful termination (server.Shutdown) is finished.
|
||||||
<-stoppedCh
|
<-stoppedCh
|
||||||
|
|
||||||
// Wait for all requests to finish, which are bounded by the RequestTimeout variable.
|
|
||||||
s.HandlerChainWaitGroup.Wait()
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user