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 @@ -837,19 +837,19 @@ func isLongRunningRequest(path string) bool {
837
837
return ok
838
838
}
839
839
840
+ var statusesNoTracePred = httplog .StatusIsNot (
841
+ http .StatusOK ,
842
+ http .StatusFound ,
843
+ http .StatusMovedPermanently ,
844
+ http .StatusTemporaryRedirect ,
845
+ http .StatusBadRequest ,
846
+ http .StatusNotFound ,
847
+ http .StatusSwitchingProtocols ,
848
+ )
849
+
840
850
// ServeHTTP responds to HTTP requests on the Kubelet.
841
851
func (s * Server ) ServeHTTP (w http.ResponseWriter , req * http.Request ) {
842
- defer httplog .NewLogged (req , & w ).StacktraceWhen (
843
- httplog .StatusIsNot (
844
- http .StatusOK ,
845
- http .StatusFound ,
846
- http .StatusMovedPermanently ,
847
- http .StatusTemporaryRedirect ,
848
- http .StatusBadRequest ,
849
- http .StatusNotFound ,
850
- http .StatusSwitchingProtocols ,
851
- ),
852
- ).Log ()
852
+ defer httplog .NewLogged (req , & w ).StacktraceWhen (statusesNoTracePred ).Log ()
853
853
854
854
// monitor http requests
855
855
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