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
99c1df19
Commit
99c1df19
authored
Feb 21, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21377 from wojtek-t/log_if_throttled
Auto commit by PR queue bot
parents
b7a89bfd
ba28dd95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
request.go
pkg/client/unversioned/request.go
+22
-12
No files found.
pkg/client/unversioned/request.go
View file @
99c1df19
...
...
@@ -46,9 +46,15 @@ import (
watchjson
"k8s.io/kubernetes/pkg/watch/json"
)
// specialParams lists parameters that are handled specially and which users of Request
// are therefore not allowed to set manually.
var
specialParams
=
sets
.
NewString
(
"timeout"
)
var
(
// specialParams lists parameters that are handled specially and which users of Request
// are therefore not allowed to set manually.
specialParams
=
sets
.
NewString
(
"timeout"
)
// longThrottleLatency defines threshold for logging requests. All requests being
// throttle for more than longThrottleLatency will be logged.
longThrottleLatency
=
50
*
time
.
Millisecond
)
func
init
()
{
metrics
.
Register
()
...
...
@@ -612,6 +618,16 @@ func (r Request) finalURLTemplate() string {
return
r
.
URL
()
.
String
()
}
func
(
r
*
Request
)
tryThrottle
()
{
now
:=
time
.
Now
()
if
r
.
throttle
!=
nil
{
r
.
throttle
.
Accept
()
}
if
latency
:=
time
.
Since
(
now
);
latency
>
longThrottleLatency
{
glog
.
Warningf
(
"Throttling request took %v, request: %s"
,
latency
,
r
.
URL
()
.
String
())
}
}
// Watch attempts to begin watching the requested location.
// Returns a watch.Interface, or an error.
func
(
r
*
Request
)
Watch
()
(
watch
.
Interface
,
error
)
{
...
...
@@ -683,9 +699,7 @@ func (r *Request) Stream() (io.ReadCloser, error) {
return
nil
,
r
.
err
}
if
r
.
throttle
!=
nil
{
r
.
throttle
.
Accept
()
}
r
.
tryThrottle
()
url
:=
r
.
URL
()
.
String
()
req
,
err
:=
http
.
NewRequest
(
r
.
verb
,
url
,
nil
)
...
...
@@ -819,9 +833,7 @@ func (r *Request) request(fn func(*http.Request, *http.Response)) error {
// * If the server responds with a status: *errors.StatusError or *errors.UnexpectedObjectError
// * http.Client.Do errors are returned directly.
func
(
r
*
Request
)
Do
()
Result
{
if
r
.
throttle
!=
nil
{
r
.
throttle
.
Accept
()
}
r
.
tryThrottle
()
var
result
Result
err
:=
r
.
request
(
func
(
req
*
http
.
Request
,
resp
*
http
.
Response
)
{
...
...
@@ -835,9 +847,7 @@ func (r *Request) Do() Result {
// DoRaw executes the request but does not process the response body.
func
(
r
*
Request
)
DoRaw
()
([]
byte
,
error
)
{
if
r
.
throttle
!=
nil
{
r
.
throttle
.
Accept
()
}
r
.
tryThrottle
()
var
result
Result
err
:=
r
.
request
(
func
(
req
*
http
.
Request
,
resp
*
http
.
Response
)
{
...
...
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