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
0f335df1
Commit
0f335df1
authored
Mar 04, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #22192 from bprashanth/timeout_client
Auto commit by PR queue bot
parents
8ba70b57
fe0f1121
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
http.go
pkg/kubelet/config/http.go
+8
-3
http_test.go
pkg/kubelet/config/http_test.go
+4
-4
No files found.
pkg/kubelet/config/http.go
View file @
0f335df1
...
...
@@ -38,6 +38,7 @@ type sourceURL struct {
updates
chan
<-
interface
{}
data
[]
byte
failureLogs
int
client
*
http
.
Client
}
func
NewSourceURL
(
url
string
,
header
http
.
Header
,
nodeName
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
{
...
...
@@ -47,6 +48,9 @@ func NewSourceURL(url string, header http.Header, nodeName string, period time.D
nodeName
:
nodeName
,
updates
:
updates
,
data
:
nil
,
// Timing out requests leads to retries. This client is only used to
// read the the manifest URL passed to kubelet.
client
:
&
http
.
Client
{
Timeout
:
10
*
time
.
Second
},
}
glog
.
V
(
1
)
.
Infof
(
"Watching URL %s"
,
url
)
go
wait
.
Until
(
config
.
run
,
period
,
wait
.
NeverStop
)
...
...
@@ -59,7 +63,9 @@ func (s *sourceURL) run() {
if
s
.
failureLogs
<
3
{
glog
.
Warningf
(
"Failed to read pods from URL: %v"
,
err
)
}
else
if
s
.
failureLogs
==
3
{
glog
.
Warningf
(
"Failed to read pods from URL. Won't log this message anymore: %v"
,
err
)
glog
.
Warningf
(
"Failed to read pods from URL. Dropping verbosity of this message to V(4): %v"
,
err
)
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Failed to read pods from URL: %v"
,
err
)
}
s
.
failureLogs
++
}
else
{
...
...
@@ -80,8 +86,7 @@ func (s *sourceURL) extractFromURL() error {
return
err
}
req
.
Header
=
s
.
header
client
:=
&
http
.
Client
{}
resp
,
err
:=
client
.
Do
(
req
)
resp
,
err
:=
s
.
client
.
Do
(
req
)
if
err
!=
nil
{
return
err
}
...
...
pkg/kubelet/config/http_test.go
View file @
0f335df1
...
...
@@ -44,7 +44,7 @@ func TestURLErrorNotExistNoUpdate(t *testing.T) {
func
TestExtractFromHttpBadness
(
t
*
testing
.
T
)
{
ch
:=
make
(
chan
interface
{},
1
)
c
:=
sourceURL
{
"http://localhost:49575/_not_found_"
,
http
.
Header
{},
"other"
,
ch
,
nil
,
0
}
c
:=
sourceURL
{
"http://localhost:49575/_not_found_"
,
http
.
Header
{},
"other"
,
ch
,
nil
,
0
,
http
.
DefaultClient
}
if
err
:=
c
.
extractFromURL
();
err
==
nil
{
t
.
Errorf
(
"Expected error"
)
}
...
...
@@ -114,7 +114,7 @@ func TestExtractInvalidPods(t *testing.T) {
// TODO: Uncomment when fix #19254
// defer testServer.Close()
ch
:=
make
(
chan
interface
{},
1
)
c
:=
sourceURL
{
testServer
.
URL
,
http
.
Header
{},
"localhost"
,
ch
,
nil
,
0
}
c
:=
sourceURL
{
testServer
.
URL
,
http
.
Header
{},
"localhost"
,
ch
,
nil
,
0
,
http
.
DefaultClient
}
if
err
:=
c
.
extractFromURL
();
err
==
nil
{
t
.
Errorf
(
"%s: Expected error"
,
testCase
.
desc
)
}
...
...
@@ -293,7 +293,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
// TODO: Uncomment when fix #19254
// defer testServer.Close()
ch
:=
make
(
chan
interface
{},
1
)
c
:=
sourceURL
{
testServer
.
URL
,
http
.
Header
{},
hostname
,
ch
,
nil
,
0
}
c
:=
sourceURL
{
testServer
.
URL
,
http
.
Header
{},
hostname
,
ch
,
nil
,
0
,
http
.
DefaultClient
}
if
err
:=
c
.
extractFromURL
();
err
!=
nil
{
t
.
Errorf
(
"%s: Unexpected error: %v"
,
testCase
.
desc
,
err
)
continue
...
...
@@ -341,7 +341,7 @@ func TestURLWithHeader(t *testing.T) {
ch
:=
make
(
chan
interface
{},
1
)
header
:=
make
(
http
.
Header
)
header
.
Set
(
"Metadata-Flavor"
,
"Google"
)
c
:=
sourceURL
{
testServer
.
URL
,
header
,
"localhost"
,
ch
,
nil
,
0
}
c
:=
sourceURL
{
testServer
.
URL
,
header
,
"localhost"
,
ch
,
nil
,
0
,
http
.
DefaultClient
}
if
err
:=
c
.
extractFromURL
();
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error extracting from URL: %v"
,
err
)
}
...
...
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