File tree Expand file tree Collapse file tree 2 files changed +17
-17
lines changed
staging/src/k8s.io/apiserver/pkg/server/httplog Expand file tree Collapse file tree 2 files changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -835,19 +835,19 @@ func isLongRunningRequest(path string) bool {
835
835
return false
836
836
}
837
837
838
+ var statusesNoTracePred = httplog .StatusIsNot (
839
+ http .StatusOK ,
840
+ http .StatusFound ,
841
+ http .StatusMovedPermanently ,
842
+ http .StatusTemporaryRedirect ,
843
+ http .StatusBadRequest ,
844
+ http .StatusNotFound ,
845
+ http .StatusSwitchingProtocols ,
846
+ )
847
+
838
848
// ServeHTTP responds to HTTP requests on the Kubelet.
839
849
func (s * Server ) ServeHTTP (w http.ResponseWriter , req * http.Request ) {
840
- defer httplog .NewLogged (req , & w ).StacktraceWhen (
841
- httplog .StatusIsNot (
842
- http .StatusOK ,
843
- http .StatusFound ,
844
- http .StatusMovedPermanently ,
845
- http .StatusTemporaryRedirect ,
846
- http .StatusBadRequest ,
847
- http .StatusNotFound ,
848
- http .StatusSwitchingProtocols ,
849
- ),
850
- ).Log ()
850
+ defer httplog .NewLogged (req , & w ).StacktraceWhen (statusesNoTracePred ).Log ()
851
851
852
852
// monitor http requests
853
853
var serverType string
Original file line number Diff line number Diff line change @@ -125,13 +125,13 @@ func (rl *respLogger) StacktraceWhen(pred StacktracePred) *respLogger {
125
125
// StatusIsNot returns a StacktracePred which will cause stacktraces to be logged
126
126
// for any status *not* in the given list.
127
127
func StatusIsNot (statuses ... int ) StacktracePred {
128
+ statusesNoTrace := map [int ]bool {}
129
+ for _ , s := range statuses {
130
+ statusesNoTrace [s ] = true
131
+ }
128
132
return func (status int ) bool {
129
- for _ , s := range statuses {
130
- if status == s {
131
- return false
132
- }
133
- }
134
- return true
133
+ _ , ok := statusesNoTrace [status ]
134
+ return ! ok
135
135
}
136
136
}
137
137
You can’t perform that action at this time.
0 commit comments