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

Remove dead RateLimit function from API server handlers #14418

Merged
merged 1 commit into from Sep 23, 2015
Merged
Show file tree
Hide file tree
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
12 changes: 0 additions & 12 deletions pkg/apiserver/handlers.go
Expand Up @@ -34,7 +34,6 @@ import (
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/httplog"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
)

Expand Down Expand Up @@ -96,17 +95,6 @@ func MaxInFlightLimit(c chan bool, longRunningRequestRE *regexp.Regexp, handler
})
}

// RateLimit uses rl to rate limit accepting requests to 'handler'.
func RateLimit(rl util.RateLimiter, handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
if rl.CanAccept() {
handler.ServeHTTP(w, req)
return
}
tooManyRequests(w)
})
}

func tooManyRequests(w http.ResponseWriter) {
// Return a 429 status indicating "Too Many Requests"
w.Header().Set("Retry-After", RetryAfter)
Expand Down
15 changes: 0 additions & 15 deletions pkg/apiserver/handlers_test.go
Expand Up @@ -110,21 +110,6 @@ func TestMaxInFlight(t *testing.T) {
expectHTTP(server.URL, http.StatusOK, t)
}

func TestRateLimit(t *testing.T) {
for _, allow := range []bool{true, false} {
rl := fakeRL(allow)
server := httptest.NewServer(RateLimit(rl, http.HandlerFunc(
func(w http.ResponseWriter, req *http.Request) {
if !allow {
t.Errorf("Unexpected call")
}
},
)))
defer server.Close()
http.Get(server.URL)
}
}

func TestReadOnly(t *testing.T) {
server := httptest.NewServer(ReadOnly(http.HandlerFunc(
func(w http.ResponseWriter, req *http.Request) {
Expand Down