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
a9f0c468
Commit
a9f0c468
authored
Jul 30, 2015
by
Alex Robinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit the logging from kubelet attempting to read its manifest URL.
Without this, it logs an error every 20 seconds if nothing is at the provided URL.
parent
cf011cad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
http.go
pkg/kubelet/config/http.go
+19
-6
http_test.go
pkg/kubelet/config/http_test.go
+4
-4
No files found.
pkg/kubelet/config/http.go
View file @
a9f0c468
...
...
@@ -32,11 +32,12 @@ import (
)
type
sourceURL
struct
{
url
string
header
http
.
Header
nodeName
string
updates
chan
<-
interface
{}
data
[]
byte
url
string
header
http
.
Header
nodeName
string
updates
chan
<-
interface
{}
data
[]
byte
failureLogs
int
}
func
NewSourceURL
(
url
string
,
header
http
.
Header
,
nodeName
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
{
...
...
@@ -53,7 +54,19 @@ func NewSourceURL(url string, header http.Header, nodeName string, period time.D
func
(
s
*
sourceURL
)
run
()
{
if
err
:=
s
.
extractFromURL
();
err
!=
nil
{
glog
.
Errorf
(
"Failed to read URL: %v"
,
err
)
// Don't log this multiple times per minute. The first few entries should be
// enough to get the point across.
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
)
}
s
.
failureLogs
++
}
else
{
if
s
.
failureLogs
>
0
{
glog
.
Info
(
"Successfully read pods from URL."
)
s
.
failureLogs
=
0
}
}
}
...
...
pkg/kubelet/config/http_test.go
View file @
a9f0c468
...
...
@@ -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
}
c
:=
sourceURL
{
"http://localhost:49575/_not_found_"
,
http
.
Header
{},
"other"
,
ch
,
nil
,
0
}
if
err
:=
c
.
extractFromURL
();
err
==
nil
{
t
.
Errorf
(
"Expected error"
)
}
...
...
@@ -113,7 +113,7 @@ func TestExtractInvalidPods(t *testing.T) {
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
defer
testServer
.
Close
()
ch
:=
make
(
chan
interface
{},
1
)
c
:=
sourceURL
{
testServer
.
URL
,
http
.
Header
{},
"localhost"
,
ch
,
nil
}
c
:=
sourceURL
{
testServer
.
URL
,
http
.
Header
{},
"localhost"
,
ch
,
nil
,
0
}
if
err
:=
c
.
extractFromURL
();
err
==
nil
{
t
.
Errorf
(
"%s: Expected error"
,
testCase
.
desc
)
}
...
...
@@ -260,7 +260,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
defer
testServer
.
Close
()
ch
:=
make
(
chan
interface
{},
1
)
c
:=
sourceURL
{
testServer
.
URL
,
http
.
Header
{},
hostname
,
ch
,
nil
}
c
:=
sourceURL
{
testServer
.
URL
,
http
.
Header
{},
hostname
,
ch
,
nil
,
0
}
if
err
:=
c
.
extractFromURL
();
err
!=
nil
{
t
.
Errorf
(
"%s: Unexpected error: %v"
,
testCase
.
desc
,
err
)
continue
...
...
@@ -307,7 +307,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
}
c
:=
sourceURL
{
testServer
.
URL
,
header
,
"localhost"
,
ch
,
nil
,
0
}
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