mirror of https://github.com/k3s-io/k3s
rename probe.Healthy to probe.Success and renam probe.Unhealthy to probe.Failure.
parent
6eb0b89cbd
commit
5dc6362f8a
|
@ -85,7 +85,7 @@ func (fakeKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.Pod
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fakeKubeletClient) HealthCheck(host string) (probe.Status, error) {
|
func (fakeKubeletClient) HealthCheck(host string) (probe.Status, error) {
|
||||||
return probe.Healthy, nil
|
return probe.Success, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type delegateHandler struct {
|
type delegateHandler struct {
|
||||||
|
|
|
@ -57,10 +57,10 @@ func (s *Server) check(client httpGet) (probe.Status, string, error) {
|
||||||
return probe.Unknown, string(data), err
|
return probe.Unknown, string(data), err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return probe.Unhealthy, string(data),
|
return probe.Failure, string(data),
|
||||||
fmt.Errorf("unhealthy http status code: %d (%s)", resp.StatusCode, resp.Status)
|
fmt.Errorf("unhealthy http status code: %d (%s)", resp.StatusCode, resp.Status)
|
||||||
}
|
}
|
||||||
return probe.Healthy, string(data), nil
|
return probe.Success, string(data), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerStatus struct {
|
type ServerStatus struct {
|
||||||
|
|
|
@ -59,8 +59,8 @@ func TestValidate(t *testing.T) {
|
||||||
expectErr bool
|
expectErr bool
|
||||||
}{
|
}{
|
||||||
{fmt.Errorf("test error"), "", probe.Unknown, 500 /*ignored*/, true},
|
{fmt.Errorf("test error"), "", probe.Unknown, 500 /*ignored*/, true},
|
||||||
{nil, "foo", probe.Healthy, 200, false},
|
{nil, "foo", probe.Success, 200, false},
|
||||||
{nil, "foo", probe.Unhealthy, 500, true},
|
{nil, "foo", probe.Failure, 500, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
s := Server{Addr: "foo.com", Port: 8080, Path: "/healthz"}
|
s := Server{Addr: "foo.com", Port: 8080, Path: "/healthz"}
|
||||||
|
|
|
@ -134,8 +134,8 @@ 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 != probe.Unhealthy {
|
if healthStatus != probe.Failure {
|
||||||
t.Errorf("Expected %v and got %v.", probe.Unhealthy, healthStatus)
|
t.Errorf("Expected %v and got %v.", probe.Failure, healthStatus)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Expected a nil error")
|
t.Error("Expected a nil error")
|
||||||
|
|
|
@ -1039,7 +1039,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
||||||
containersToKeep[containerID] = empty{}
|
containersToKeep[containerID] = empty{}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if healthy == probe.Healthy {
|
if healthy == probe.Success {
|
||||||
containersToKeep[containerID] = empty{}
|
containersToKeep[containerID] = empty{}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -1401,10 +1401,10 @@ func (kl *Kubelet) GetPodStatus(podFullName string, uid types.UID) (api.PodStatu
|
||||||
func (kl *Kubelet) probeLiveness(podFullName string, podUID types.UID, status api.PodStatus, container api.Container, dockerContainer *docker.APIContainers) (probe.Status, error) {
|
func (kl *Kubelet) probeLiveness(podFullName string, podUID types.UID, status api.PodStatus, container api.Container, dockerContainer *docker.APIContainers) (probe.Status, 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.Healthy, nil
|
return probe.Success, nil
|
||||||
}
|
}
|
||||||
if time.Now().Unix()-dockerContainer.Created < container.LivenessProbe.InitialDelaySeconds {
|
if time.Now().Unix()-dockerContainer.Created < container.LivenessProbe.InitialDelaySeconds {
|
||||||
return probe.Healthy, nil
|
return probe.Success, nil
|
||||||
}
|
}
|
||||||
return kl.probeContainer(container.LivenessProbe, podFullName, podUID, status, container)
|
return kl.probeContainer(container.LivenessProbe, podFullName, podUID, status, container)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (pr ExecProber) Probe(e uexec.Cmd) (probe.Status, error) {
|
||||||
return probe.Unknown, err
|
return probe.Unknown, err
|
||||||
}
|
}
|
||||||
if strings.ToLower(string(data)) != defaultHealthyOutput {
|
if strings.ToLower(string(data)) != defaultHealthyOutput {
|
||||||
return probe.Unhealthy, nil
|
return probe.Failure, nil
|
||||||
}
|
}
|
||||||
return probe.Healthy, nil
|
return probe.Success, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,11 +46,11 @@ func TestExec(t *testing.T) {
|
||||||
fake := FakeCmd{}
|
fake := FakeCmd{}
|
||||||
tests := []healthCheckTest{
|
tests := []healthCheckTest{
|
||||||
// Ok
|
// Ok
|
||||||
{probe.Healthy, false, []byte("OK"), nil},
|
{probe.Success, false, []byte("OK"), nil},
|
||||||
// Run returns error
|
// Run returns error
|
||||||
{probe.Unknown, true, []byte("OK, NOT"), fmt.Errorf("test error")},
|
{probe.Unknown, true, []byte("OK, NOT"), fmt.Errorf("test error")},
|
||||||
// Unhealthy
|
// Unhealthy
|
||||||
{probe.Unhealthy, false, []byte("Fail"), nil},
|
{probe.Failure, false, []byte("Fail"), nil},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
fake.out = test.output
|
fake.out = test.output
|
||||||
|
|
|
@ -52,14 +52,14 @@ func DoHTTPProbe(url string, client HTTPGetInterface) (probe.Status, 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)
|
||||||
return probe.Unhealthy, nil
|
return probe.Failure, 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 {
|
||||||
return probe.Healthy, nil
|
return probe.Success, nil
|
||||||
}
|
}
|
||||||
glog.V(1).Infof("Health check failed for %s, Response: %v", url, *res)
|
glog.V(1).Infof("Health check failed for %s, Response: %v", url, *res)
|
||||||
return probe.Unhealthy, nil
|
return probe.Failure, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// formatURL formats a URL from args. For testability.
|
// formatURL formats a URL from args. For testability.
|
||||||
|
|
|
@ -52,8 +52,8 @@ func TestHTTPProbeChecker(t *testing.T) {
|
||||||
health probe.Status
|
health probe.Status
|
||||||
}{
|
}{
|
||||||
// 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.
|
||||||
{http.StatusOK, probe.Healthy},
|
{http.StatusOK, probe.Success},
|
||||||
{-1, probe.Unhealthy},
|
{-1, probe.Failure},
|
||||||
}
|
}
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -20,17 +20,17 @@ type Status int
|
||||||
|
|
||||||
// Status values must be one of these constants.
|
// Status values must be one of these constants.
|
||||||
const (
|
const (
|
||||||
Healthy Status = iota
|
Success Status = iota
|
||||||
Unhealthy
|
Failure
|
||||||
Unknown
|
Unknown
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s Status) String() string {
|
func (s Status) String() string {
|
||||||
switch s {
|
switch s {
|
||||||
case Healthy:
|
case Success:
|
||||||
return "healthy"
|
return "success"
|
||||||
case Unhealthy:
|
case Failure:
|
||||||
return "unhealthy"
|
return "failure"
|
||||||
default:
|
default:
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,11 @@ func (pr TCPProber) Probe(host string, port int) (probe.Status, error) {
|
||||||
func DoTCPProbe(addr string) (probe.Status, error) {
|
func DoTCPProbe(addr string) (probe.Status, error) {
|
||||||
conn, err := net.Dial("tcp", addr)
|
conn, err := net.Dial("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return probe.Unhealthy, nil
|
return probe.Failure, nil
|
||||||
}
|
}
|
||||||
err = conn.Close()
|
err = conn.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unexpected error closing health check socket: %v (%#v)", err, err)
|
glog.Errorf("unexpected error closing health check socket: %v (%#v)", err, err)
|
||||||
}
|
}
|
||||||
return probe.Healthy, nil
|
return probe.Success, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ func TestTcpHealthChecker(t *testing.T) {
|
||||||
expectError bool
|
expectError bool
|
||||||
}{
|
}{
|
||||||
// The probe will be filled in below. This is primarily testing that a connection is made.
|
// The probe will be filled in below. This is primarily testing that a connection is made.
|
||||||
{probe.Healthy, true, false},
|
{probe.Success, true, false},
|
||||||
{probe.Unhealthy, false, false},
|
{probe.Failure, false, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -115,7 +115,7 @@ func (r *HealthyRegistry) doCheck(key string) util.T {
|
||||||
case err != nil:
|
case err != nil:
|
||||||
glog.V(2).Infof("HealthyRegistry: node %q health check error: %v", key, err)
|
glog.V(2).Infof("HealthyRegistry: node %q health check error: %v", key, err)
|
||||||
nodeStatus = api.ConditionUnknown
|
nodeStatus = api.ConditionUnknown
|
||||||
case status == probe.Unhealthy:
|
case status == probe.Failure:
|
||||||
nodeStatus = api.ConditionNone
|
nodeStatus = api.ConditionNone
|
||||||
default:
|
default:
|
||||||
nodeStatus = api.ConditionFull
|
nodeStatus = api.ConditionFull
|
||||||
|
|
|
@ -30,7 +30,7 @@ import (
|
||||||
type alwaysYes struct{}
|
type alwaysYes struct{}
|
||||||
|
|
||||||
func (alwaysYes) HealthCheck(host string) (probe.Status, error) {
|
func (alwaysYes) HealthCheck(host string) (probe.Status, error) {
|
||||||
return probe.Healthy, nil
|
return probe.Success, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBasicDelegation(t *testing.T) {
|
func TestBasicDelegation(t *testing.T) {
|
||||||
|
@ -77,9 +77,9 @@ type notMinion struct {
|
||||||
|
|
||||||
func (n *notMinion) HealthCheck(host string) (probe.Status, error) {
|
func (n *notMinion) HealthCheck(host string) (probe.Status, error) {
|
||||||
if host != n.minion {
|
if host != n.minion {
|
||||||
return probe.Healthy, nil
|
return probe.Success, nil
|
||||||
} else {
|
} else {
|
||||||
return probe.Unhealthy, nil
|
return probe.Failure, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue