Skip to content

Commit 6a8a368

Browse files
authored
Merge pull request kubernetes#77287 from tedyu/kube-long-running
Use map to check for long-running request
2 parents c821eb3 + fe6e50d commit 6a8a368

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pkg/kubelet/server/server.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -824,15 +824,17 @@ func trimURLPath(path string) string {
824824
return parts[0]
825825
}
826826

827+
var longRunningRequestPathMap = map[string]bool{
828+
"exec": true,
829+
"attach": true,
830+
"portforward": true,
831+
"debug": true,
832+
}
833+
827834
// isLongRunningRequest determines whether the request is long-running or not.
828835
func isLongRunningRequest(path string) bool {
829-
longRunningRequestPaths := []string{"exec", "attach", "portforward", "debug"}
830-
for _, p := range longRunningRequestPaths {
831-
if p == path {
832-
return true
833-
}
834-
}
835-
return false
836+
_, ok := longRunningRequestPathMap[path]
837+
return ok
836838
}
837839

838840
// ServeHTTP responds to HTTP requests on the Kubelet.

0 commit comments

Comments
 (0)