apiserver: all bookkeeping must complete before apf handler returns
all bookkeeping must complete before the apf handler returns, whether it panics or returns normally Kubernetes-commit: 71d9307eaeda86d6a205548ecdeb7fbf226d7d82
This commit is contained in:
parent
a785076ef7
commit
4483cc97cf
|
|
@ -266,9 +266,10 @@ func (h *priorityAndFairnessHandler) Handle(w http.ResponseWriter, r *http.Reque
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-shouldStartWatchCh:
|
case <-shouldStartWatchCh:
|
||||||
watchCtx := utilflowcontrol.WithInitializationSignal(ctx, watchInitializationSignal)
|
func() {
|
||||||
watchReq = r.WithContext(watchCtx)
|
// TODO: if both goroutines panic, propagate the stack traces from both
|
||||||
h.handler.ServeHTTP(w, watchReq)
|
// goroutines so they are logged properly:
|
||||||
|
defer func() {
|
||||||
// Protect from the situation when request will not reach storage layer
|
// Protect from the situation when request will not reach storage layer
|
||||||
// and the initialization signal will not be send.
|
// and the initialization signal will not be send.
|
||||||
// It has to happen before waiting on the resultCh below.
|
// It has to happen before waiting on the resultCh below.
|
||||||
|
|
@ -277,6 +278,11 @@ func (h *priorityAndFairnessHandler) Handle(w http.ResponseWriter, r *http.Reque
|
||||||
if err := <-resultCh; err != nil {
|
if err := <-resultCh; err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
watchCtx := utilflowcontrol.WithInitializationSignal(ctx, watchInitializationSignal)
|
||||||
|
watchReq = r.WithContext(watchCtx)
|
||||||
|
h.handler.ServeHTTP(w, watchReq)
|
||||||
|
}()
|
||||||
case err := <-resultCh:
|
case err := <-resultCh:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue