Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
72992ae8
Commit
72992ae8
authored
Sep 23, 2015
by
Eric Tune
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14418 from gmarek/dead-code
Remove dead RateLimit function from API server handlers
parents
13821de1
9d57f2c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
27 deletions
+0
-27
handlers.go
pkg/apiserver/handlers.go
+0
-12
handlers_test.go
pkg/apiserver/handlers_test.go
+0
-15
No files found.
pkg/apiserver/handlers.go
View file @
72992ae8
...
@@ -34,7 +34,6 @@ import (
...
@@ -34,7 +34,6 @@ import (
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/httplog"
"k8s.io/kubernetes/pkg/httplog"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/sets"
)
)
...
@@ -96,17 +95,6 @@ func MaxInFlightLimit(c chan bool, longRunningRequestRE *regexp.Regexp, handler
...
@@ -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
)
{
func
tooManyRequests
(
w
http
.
ResponseWriter
)
{
// Return a 429 status indicating "Too Many Requests"
// Return a 429 status indicating "Too Many Requests"
w
.
Header
()
.
Set
(
"Retry-After"
,
RetryAfter
)
w
.
Header
()
.
Set
(
"Retry-After"
,
RetryAfter
)
...
...
pkg/apiserver/handlers_test.go
View file @
72992ae8
...
@@ -110,21 +110,6 @@ func TestMaxInFlight(t *testing.T) {
...
@@ -110,21 +110,6 @@ func TestMaxInFlight(t *testing.T) {
expectHTTP
(
server
.
URL
,
http
.
StatusOK
,
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
)
{
func
TestReadOnly
(
t
*
testing
.
T
)
{
server
:=
httptest
.
NewServer
(
ReadOnly
(
http
.
HandlerFunc
(
server
:=
httptest
.
NewServer
(
ReadOnly
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment