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