Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use map to check for long-running request #77287

Merged
merged 1 commit into from
May 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions pkg/kubelet/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,15 +824,17 @@ func trimURLPath(path string) string {
return parts[0]
}

var longRunningRequestPathMap = map[string]bool{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we keep this variable local to isLongRunningRequest? We can promote it to package visible later if we have a good reason to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is not to compose the map every time isLongRunningRequest is called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes great point :)

"exec": true,
"attach": true,
"portforward": true,
"debug": true,
}

// isLongRunningRequest determines whether the request is long-running or not.
func isLongRunningRequest(path string) bool {
longRunningRequestPaths := []string{"exec", "attach", "portforward", "debug"}
for _, p := range longRunningRequestPaths {
if p == path {
return true
}
}
return false
_, ok := longRunningRequestPathMap[path]
return ok
}

// ServeHTTP responds to HTTP requests on the Kubelet.
Expand Down