mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 21:12:07 +00:00
apiserver: all bookkeeping must complete before apf handler returns
all bookkeeping must complete before the apf handler returns, whether it panics or returns normally
This commit is contained in:
parent
0c8632de57
commit
71d9307eae
@ -266,17 +266,23 @@ 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:
|
||||||
// Protect from the situation when request will not reach storage layer
|
defer func() {
|
||||||
// and the initialization signal will not be send.
|
// Protect from the situation when request will not reach storage layer
|
||||||
// It has to happen before waiting on the resultCh below.
|
// and the initialization signal will not be send.
|
||||||
watchInitializationSignal.Signal()
|
// It has to happen before waiting on the resultCh below.
|
||||||
// TODO: Consider finishing the request as soon as Handle call panics.
|
watchInitializationSignal.Signal()
|
||||||
if err := <-resultCh; err != nil {
|
// TODO: Consider finishing the request as soon as Handle call panics.
|
||||||
panic(err)
|
if err := <-resultCh; err != nil {
|
||||||
}
|
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
Block a user