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
99acb968
Commit
99acb968
authored
Dec 23, 2014
by
saadali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have Http Probe report "Unhealthy" on connection failure instead of "Unknown".
parent
ebb448df
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
9 deletions
+9
-9
kubelet_test.go
pkg/client/kubelet_test.go
+4
-4
health_test.go
pkg/health/health_test.go
+2
-2
http.go
pkg/health/http.go
+3
-3
No files found.
pkg/client/kubelet_test.go
View file @
99acb968
...
@@ -131,10 +131,10 @@ func TestNewKubeletClient(t *testing.T) {
...
@@ -131,10 +131,10 @@ func TestNewKubeletClient(t *testing.T) {
host
:=
"127.0.0.1"
host
:=
"127.0.0.1"
healthStatus
,
err
:=
client
.
HealthCheck
(
host
)
healthStatus
,
err
:=
client
.
HealthCheck
(
host
)
if
healthStatus
!=
health
.
Un
known
{
if
healthStatus
!=
health
.
Un
healthy
{
t
.
Errorf
(
"Expected %v and got %v."
,
health
.
Un
known
,
healthStatus
)
t
.
Errorf
(
"Expected %v and got %v."
,
health
.
Un
healthy
,
healthStatus
)
}
}
if
err
=
=
nil
{
if
err
!
=
nil
{
t
.
Error
(
"Expected a n
on n
il error"
)
t
.
Error
(
"Expected a nil error"
)
}
}
}
}
pkg/health/health_test.go
View file @
99acb968
...
@@ -36,7 +36,7 @@ func TestHealthChecker(t *testing.T) {
...
@@ -36,7 +36,7 @@ func TestHealthChecker(t *testing.T) {
health
Status
health
Status
}{
}{
{
http
.
StatusOK
,
Healthy
},
{
http
.
StatusOK
,
Healthy
},
{
statusServerEarlyShutdown
,
Un
known
},
{
statusServerEarlyShutdown
,
Un
healthy
},
{
http
.
StatusBadRequest
,
Unhealthy
},
{
http
.
StatusBadRequest
,
Unhealthy
},
{
http
.
StatusBadGateway
,
Unhealthy
},
{
http
.
StatusBadGateway
,
Unhealthy
},
{
http
.
StatusInternalServerError
,
Unhealthy
},
{
http
.
StatusInternalServerError
,
Unhealthy
},
...
@@ -69,7 +69,7 @@ func TestHealthChecker(t *testing.T) {
...
@@ -69,7 +69,7 @@ func TestHealthChecker(t *testing.T) {
}
}
hc
:=
NewHealthChecker
()
hc
:=
NewHealthChecker
()
health
,
err
:=
hc
.
HealthCheck
(
"test"
,
""
,
api
.
PodStatus
{},
container
)
health
,
err
:=
hc
.
HealthCheck
(
"test"
,
""
,
api
.
PodStatus
{},
container
)
if
err
!=
nil
&&
tt
.
health
!=
Un
known
{
if
err
!=
nil
&&
tt
.
health
!=
Un
healthy
{
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
}
}
if
health
!=
tt
.
health
{
if
health
!=
tt
.
health
{
...
...
pkg/health/http.go
View file @
99acb968
...
@@ -88,13 +88,13 @@ func formatURL(host string, port int, path string) string {
...
@@ -88,13 +88,13 @@ func formatURL(host string, port int, path string) string {
// DoHTTPCheck checks if a GET request to the url succeeds.
// DoHTTPCheck checks if a GET request to the url succeeds.
// If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Healthy.
// If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Healthy.
// If the HTTP response code is unsuccessful, it returns Unhealthy.
// If the HTTP response code is unsuccessful or HTTP communication fails, it returns Unhealthy.
// It returns Unknown and err if the HTTP communication itself fails.
// This is exported because some other packages may want to do direct HTTP checks.
// This is exported because some other packages may want to do direct HTTP checks.
func
DoHTTPCheck
(
url
string
,
client
HTTPGetInterface
)
(
Status
,
error
)
{
func
DoHTTPCheck
(
url
string
,
client
HTTPGetInterface
)
(
Status
,
error
)
{
res
,
err
:=
client
.
Get
(
url
)
res
,
err
:=
client
.
Get
(
url
)
if
err
!=
nil
{
if
err
!=
nil
{
return
Unknown
,
err
glog
.
V
(
1
)
.
Infof
(
"HTTP probe error: %v"
,
err
)
return
Unhealthy
,
nil
}
}
defer
res
.
Body
.
Close
()
defer
res
.
Body
.
Close
()
if
res
.
StatusCode
>=
http
.
StatusOK
&&
res
.
StatusCode
<
http
.
StatusBadRequest
{
if
res
.
StatusCode
>=
http
.
StatusOK
&&
res
.
StatusCode
<
http
.
StatusBadRequest
{
...
...
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