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
ae6e25f4
Commit
ae6e25f4
authored
Feb 05, 2015
by
Tim Hockin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4001 from mikedanese/probe-result
rename probe.Status to probe.Result
parents
8e6f5c72
14bfec92
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
22 additions
and
23 deletions
+22
-23
integration.go
cmd/integration/integration.go
+1
-1
validator.go
pkg/apiserver/validator.go
+2
-2
validator_test.go
pkg/apiserver/validator_test.go
+1
-1
kubelet.go
pkg/client/kubelet.go
+3
-3
nodecontroller_test.go
pkg/cloudprovider/controller/nodecontroller_test.go
+2
-2
kubelet.go
pkg/kubelet/kubelet.go
+1
-1
probe.go
pkg/kubelet/probe.go
+1
-2
exec.go
pkg/probe/exec/exec.go
+1
-1
exec_test.go
pkg/probe/exec/exec_test.go
+1
-1
http.go
pkg/probe/http/http.go
+2
-2
http_test.go
pkg/probe/http/http_test.go
+1
-1
probe.go
pkg/probe/probe.go
+3
-3
tcp.go
pkg/probe/tcp/tcp.go
+2
-2
tcp_test.go
pkg/probe/tcp/tcp_test.go
+1
-1
No files found.
cmd/integration/integration.go
View file @
ae6e25f4
...
...
@@ -96,7 +96,7 @@ func (fakeKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.Pod
return
r
,
nil
}
func
(
fakeKubeletClient
)
HealthCheck
(
host
string
)
(
probe
.
Status
,
error
)
{
func
(
fakeKubeletClient
)
HealthCheck
(
host
string
)
(
probe
.
Result
,
error
)
{
return
probe
.
Success
,
nil
}
...
...
pkg/apiserver/validator.go
View file @
ae6e25f4
...
...
@@ -46,7 +46,7 @@ type validator struct {
}
// TODO: can this use pkg/probe/http
func
(
s
*
Server
)
check
(
client
httpGet
)
(
probe
.
Status
,
string
,
error
)
{
func
(
s
*
Server
)
check
(
client
httpGet
)
(
probe
.
Result
,
string
,
error
)
{
resp
,
err
:=
client
.
Get
(
"http://"
+
net
.
JoinHostPort
(
s
.
Addr
,
strconv
.
Itoa
(
s
.
Port
))
+
s
.
Path
)
if
err
!=
nil
{
return
probe
.
Unknown
,
""
,
err
...
...
@@ -66,7 +66,7 @@ func (s *Server) check(client httpGet) (probe.Status, string, error) {
type
ServerStatus
struct
{
Component
string
`json:"component,omitempty"`
Health
string
`json:"health,omitempty"`
HealthCode
probe
.
Status
`json:"healthCode,omitempty"`
HealthCode
probe
.
Result
`json:"healthCode,omitempty"`
Msg
string
`json:"msg,omitempty"`
Err
string
`json:"err,omitempty"`
}
...
...
pkg/apiserver/validator_test.go
View file @
ae6e25f4
...
...
@@ -54,7 +54,7 @@ func TestValidate(t *testing.T) {
tests
:=
[]
struct
{
err
error
data
string
expectedStatus
probe
.
Status
expectedStatus
probe
.
Result
code
int
expectErr
bool
}{
...
...
pkg/client/kubelet.go
View file @
ae6e25f4
...
...
@@ -41,7 +41,7 @@ type KubeletClient interface {
// KubeletHealthchecker is an interface for healthchecking kubelets
type
KubeletHealthChecker
interface
{
HealthCheck
(
host
string
)
(
probe
.
Status
,
error
)
HealthCheck
(
host
string
)
(
probe
.
Result
,
error
)
}
// PodInfoGetter is an interface for things that can get information about a pod's containers.
...
...
@@ -134,7 +134,7 @@ func (c *HTTPKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.
return
status
,
nil
}
func
(
c
*
HTTPKubeletClient
)
HealthCheck
(
host
string
)
(
probe
.
Status
,
error
)
{
func
(
c
*
HTTPKubeletClient
)
HealthCheck
(
host
string
)
(
probe
.
Result
,
error
)
{
return
httprobe
.
DoHTTPProbe
(
fmt
.
Sprintf
(
"%s/healthz"
,
c
.
url
(
host
)),
c
.
Client
)
}
...
...
@@ -148,6 +148,6 @@ func (c FakeKubeletClient) GetPodStatus(host, podNamespace string, podID string)
return
api
.
PodStatusResult
{},
errors
.
New
(
"Not Implemented"
)
}
func
(
c
FakeKubeletClient
)
HealthCheck
(
host
string
)
(
probe
.
Status
,
error
)
{
func
(
c
FakeKubeletClient
)
HealthCheck
(
host
string
)
(
probe
.
Result
,
error
)
{
return
probe
.
Unknown
,
errors
.
New
(
"Not Implemented"
)
}
pkg/cloudprovider/controller/nodecontroller_test.go
View file @
ae6e25f4
...
...
@@ -102,7 +102,7 @@ func (m *FakeNodeHandler) Update(node *api.Node) (*api.Node, error) {
// FakeKubeletClient is a fake implementation of KubeletClient.
type
FakeKubeletClient
struct
{
Status
probe
.
Status
Status
probe
.
Result
Err
error
}
...
...
@@ -110,7 +110,7 @@ func (c *FakeKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.
return
api
.
PodStatusResult
{},
errors
.
New
(
"Not Implemented"
)
}
func
(
c
*
FakeKubeletClient
)
HealthCheck
(
host
string
)
(
probe
.
Status
,
error
)
{
func
(
c
*
FakeKubeletClient
)
HealthCheck
(
host
string
)
(
probe
.
Result
,
error
)
{
return
c
.
Status
,
c
.
Err
}
...
...
pkg/kubelet/kubelet.go
View file @
ae6e25f4
...
...
@@ -1446,7 +1446,7 @@ func (kl *Kubelet) GetPodStatus(podFullName string, uid types.UID) (api.PodStatu
return
podStatus
,
err
}
func
(
kl
*
Kubelet
)
probeLiveness
(
podFullName
string
,
podUID
types
.
UID
,
status
api
.
PodStatus
,
container
api
.
Container
,
dockerContainer
*
docker
.
APIContainers
)
(
healthStatus
probe
.
Status
,
err
error
)
{
func
(
kl
*
Kubelet
)
probeLiveness
(
podFullName
string
,
podUID
types
.
UID
,
status
api
.
PodStatus
,
container
api
.
Container
,
dockerContainer
*
docker
.
APIContainers
)
(
healthStatus
probe
.
Result
,
err
error
)
{
// Give the container 60 seconds to start up.
if
container
.
LivenessProbe
==
nil
{
return
probe
.
Success
,
nil
...
...
pkg/kubelet/probe.go
View file @
ae6e25f4
...
...
@@ -39,7 +39,7 @@ var (
tcprober
=
tcprobe
.
New
()
)
func
(
kl
*
Kubelet
)
probeContainer
(
p
*
api
.
Probe
,
podFullName
string
,
podUID
types
.
UID
,
status
api
.
PodStatus
,
container
api
.
Container
)
(
probe
.
Status
,
error
)
{
func
(
kl
*
Kubelet
)
probeContainer
(
p
*
api
.
Probe
,
podFullName
string
,
podUID
types
.
UID
,
status
api
.
PodStatus
,
container
api
.
Container
)
(
probe
.
Result
,
error
)
{
var
timeout
time
.
Duration
secs
:=
container
.
LivenessProbe
.
TimeoutSeconds
if
secs
>
0
{
...
...
@@ -47,7 +47,6 @@ func (kl *Kubelet) probeContainer(p *api.Probe, podFullName string, podUID types
}
else
{
timeout
=
1
*
time
.
Second
}
if
p
.
Exec
!=
nil
{
return
execprober
.
Probe
(
kl
.
newExecInContainer
(
podFullName
,
podUID
,
container
))
}
...
...
pkg/probe/exec/exec.go
View file @
ae6e25f4
...
...
@@ -33,7 +33,7 @@ func New() ExecProber {
type
ExecProber
struct
{}
func
(
pr
ExecProber
)
Probe
(
e
uexec
.
Cmd
)
(
probe
.
Status
,
error
)
{
func
(
pr
ExecProber
)
Probe
(
e
uexec
.
Cmd
)
(
probe
.
Result
,
error
)
{
data
,
err
:=
e
.
CombinedOutput
()
glog
.
V
(
4
)
.
Infof
(
"health check response: %s"
,
string
(
data
))
if
err
!=
nil
{
...
...
pkg/probe/exec/exec_test.go
View file @
ae6e25f4
...
...
@@ -35,7 +35,7 @@ func (f *FakeCmd) CombinedOutput() ([]byte, error) {
func
(
f
*
FakeCmd
)
SetDir
(
dir
string
)
{}
type
healthCheckTest
struct
{
expectedStatus
probe
.
Status
expectedStatus
probe
.
Result
expectError
bool
output
[]
byte
err
error
...
...
pkg/probe/http/http.go
View file @
ae6e25f4
...
...
@@ -38,7 +38,7 @@ type HTTPProber struct {
}
// Probe returns a ProbeRunner capable of running an http check.
func
(
pr
*
HTTPProber
)
Probe
(
host
string
,
port
int
,
path
string
,
timeout
time
.
Duration
)
(
probe
.
Status
,
error
)
{
func
(
pr
*
HTTPProber
)
Probe
(
host
string
,
port
int
,
path
string
,
timeout
time
.
Duration
)
(
probe
.
Result
,
error
)
{
return
DoHTTPProbe
(
formatURL
(
host
,
port
,
path
),
&
http
.
Client
{
Timeout
:
timeout
,
Transport
:
pr
.
transport
})
}
...
...
@@ -50,7 +50,7 @@ type HTTPGetInterface interface {
// If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Success.
// If the HTTP response code is unsuccessful or HTTP communication fails, it returns Failure.
// This is exported because some other packages may want to do direct HTTP probes.
func
DoHTTPProbe
(
url
string
,
client
HTTPGetInterface
)
(
probe
.
Status
,
error
)
{
func
DoHTTPProbe
(
url
string
,
client
HTTPGetInterface
)
(
probe
.
Result
,
error
)
{
res
,
err
:=
client
.
Get
(
url
)
if
err
!=
nil
{
glog
.
V
(
1
)
.
Infof
(
"HTTP probe error: %v"
,
err
)
...
...
pkg/probe/http/http_test.go
View file @
ae6e25f4
...
...
@@ -54,7 +54,7 @@ func TestHTTPProbeChecker(t *testing.T) {
prober
:=
New
()
testCases
:=
[]
struct
{
handler
func
(
w
http
.
ResponseWriter
)
health
probe
.
Status
health
probe
.
Result
}{
// The probe will be filled in below. This is primarily testing that an HTTP GET happens.
{
handleReq
(
http
.
StatusOK
),
probe
.
Success
},
...
...
pkg/probe/probe.go
View file @
ae6e25f4
...
...
@@ -16,16 +16,16 @@ limitations under the License.
package
probe
type
Status
int
type
Result
int
// Status values must be one of these constants.
const
(
Success
Status
=
iota
Success
Result
=
iota
Failure
Unknown
)
func
(
s
Status
)
String
()
string
{
func
(
s
Result
)
String
()
string
{
switch
s
{
case
Success
:
return
"success"
...
...
pkg/probe/tcp/tcp.go
View file @
ae6e25f4
...
...
@@ -32,7 +32,7 @@ func New() TCPProber {
type
TCPProber
struct
{}
func
(
pr
TCPProber
)
Probe
(
host
string
,
port
int
,
timeout
time
.
Duration
)
(
probe
.
Status
,
error
)
{
func
(
pr
TCPProber
)
Probe
(
host
string
,
port
int
,
timeout
time
.
Duration
)
(
probe
.
Result
,
error
)
{
return
DoTCPProbe
(
net
.
JoinHostPort
(
host
,
strconv
.
Itoa
(
port
)),
timeout
)
}
...
...
@@ -40,7 +40,7 @@ func (pr TCPProber) Probe(host string, port int, timeout time.Duration) (probe.S
// If the socket can be opened, it returns Success
// If the socket fails to open, it returns Failure.
// This is exported because some other packages may want to do direct TCP probes.
func
DoTCPProbe
(
addr
string
,
timeout
time
.
Duration
)
(
probe
.
Status
,
error
)
{
func
DoTCPProbe
(
addr
string
,
timeout
time
.
Duration
)
(
probe
.
Result
,
error
)
{
conn
,
err
:=
net
.
DialTimeout
(
"tcp"
,
addr
,
timeout
)
if
err
!=
nil
{
return
probe
.
Failure
,
nil
...
...
pkg/probe/tcp/tcp_test.go
View file @
ae6e25f4
...
...
@@ -31,7 +31,7 @@ import (
func
TestTcpHealthChecker
(
t
*
testing
.
T
)
{
prober
:=
New
()
tests
:=
[]
struct
{
expectedStatus
probe
.
Status
expectedStatus
probe
.
Result
usePort
bool
expectError
bool
}{
...
...
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