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
1a704216
Commit
1a704216
authored
Dec 29, 2014
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3144 from saad-ali/3041ChangeUnhealthyStatus
Have Http Liveness Probe report "Unhealthy" on connection failure instead of "Unknown"
parents
ebb448df
99acb968
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 @
1a704216
...
...
@@ -131,10 +131,10 @@ func TestNewKubeletClient(t *testing.T) {
host
:=
"127.0.0.1"
healthStatus
,
err
:=
client
.
HealthCheck
(
host
)
if
healthStatus
!=
health
.
Un
known
{
t
.
Errorf
(
"Expected %v and got %v."
,
health
.
Un
known
,
healthStatus
)
if
healthStatus
!=
health
.
Un
healthy
{
t
.
Errorf
(
"Expected %v and got %v."
,
health
.
Un
healthy
,
healthStatus
)
}
if
err
=
=
nil
{
t
.
Error
(
"Expected a n
on n
il error"
)
if
err
!
=
nil
{
t
.
Error
(
"Expected a nil error"
)
}
}
pkg/health/health_test.go
View file @
1a704216
...
...
@@ -36,7 +36,7 @@ func TestHealthChecker(t *testing.T) {
health
Status
}{
{
http
.
StatusOK
,
Healthy
},
{
statusServerEarlyShutdown
,
Un
known
},
{
statusServerEarlyShutdown
,
Un
healthy
},
{
http
.
StatusBadRequest
,
Unhealthy
},
{
http
.
StatusBadGateway
,
Unhealthy
},
{
http
.
StatusInternalServerError
,
Unhealthy
},
...
...
@@ -69,7 +69,7 @@ func TestHealthChecker(t *testing.T) {
}
hc
:=
NewHealthChecker
()
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
)
}
if
health
!=
tt
.
health
{
...
...
pkg/health/http.go
View file @
1a704216
...
...
@@ -88,13 +88,13 @@ func formatURL(host string, port int, path string) string {
// 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 unsuccessful, it returns Unhealthy.
// It returns Unknown and err if the HTTP communication itself fails.
// If the HTTP response code is unsuccessful or HTTP communication fails, it returns Unhealthy.
// This is exported because some other packages may want to do direct HTTP checks.
func
DoHTTPCheck
(
url
string
,
client
HTTPGetInterface
)
(
Status
,
error
)
{
res
,
err
:=
client
.
Get
(
url
)
if
err
!=
nil
{
return
Unknown
,
err
glog
.
V
(
1
)
.
Infof
(
"HTTP probe error: %v"
,
err
)
return
Unhealthy
,
nil
}
defer
res
.
Body
.
Close
()
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