Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions staging/src/k8s.io/apiserver/pkg/server/httplog/httplog.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,15 @@ func withLogging(handler http.Handler, stackTracePred StacktracePred, shouldLogR
req = req.WithContext(context.WithValue(ctx, respLoggerContextKey, rl))

var logFunc func()
logFunc = rl.Log
if klog.V(3).Enabled() || (rl.isTerminating && klog.V(1).Enabled()) {
logFunc = rl.Log
}
defer func() {
if logFunc != nil {
logFunc()
}
}()

if klog.V(3).Enabled() || (rl.isTerminating && klog.V(1).Enabled()) {
defer rl.Log()
}
w = responsewriter.WrapForHTTP1Or2(rl)
handler.ServeHTTP(w, req)

Expand All @@ -149,7 +148,7 @@ func withLogging(handler http.Handler, stackTracePred StacktracePred, shouldLogR
// WithRoutine handler in the handler chain (i.e. above handler.ServeHTTP()
// would return request is completely responsed), we want the logging to
// happen in that goroutine too, so we append it to the task.
if routine.AppendTask(ctx, &routine.Task{Func: rl.Log}) {
if logFunc != nil && routine.AppendTask(ctx, &routine.Task{Func: logFunc}) {
logFunc = nil
}
})
Expand Down