mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-12 12:48:51 +00:00
rename probe.Healthy to probe.Success and renam probe.Unhealthy to probe.Failure.
This commit is contained in:
@@ -40,7 +40,7 @@ func (pr ExecProber) Probe(e uexec.Cmd) (probe.Status, error) {
|
||||
return probe.Unknown, err
|
||||
}
|
||||
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{}
|
||||
tests := []healthCheckTest{
|
||||
// Ok
|
||||
{probe.Healthy, false, []byte("OK"), nil},
|
||||
{probe.Success, false, []byte("OK"), nil},
|
||||
// Run returns error
|
||||
{probe.Unknown, true, []byte("OK, NOT"), fmt.Errorf("test error")},
|
||||
// Unhealthy
|
||||
{probe.Unhealthy, false, []byte("Fail"), nil},
|
||||
{probe.Failure, false, []byte("Fail"), nil},
|
||||
}
|
||||
for _, test := range tests {
|
||||
fake.out = test.output
|
||||
|
@@ -52,14 +52,14 @@ func DoHTTPProbe(url string, client HTTPGetInterface) (probe.Status, error) {
|
||||
res, err := client.Get(url)
|
||||
if err != nil {
|
||||
glog.V(1).Infof("HTTP probe error: %v", err)
|
||||
return probe.Unhealthy, nil
|
||||
return probe.Failure, nil
|
||||
}
|
||||
defer res.Body.Close()
|
||||
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)
|
||||
return probe.Unhealthy, nil
|
||||
return probe.Failure, nil
|
||||
}
|
||||
|
||||
// formatURL formats a URL from args. For testability.
|
||||
|
@@ -52,8 +52,8 @@ func TestHTTPProbeChecker(t *testing.T) {
|
||||
health probe.Status
|
||||
}{
|
||||
// The probe will be filled in below. This is primarily testing that an HTTP GET happens.
|
||||
{http.StatusOK, probe.Healthy},
|
||||
{-1, probe.Unhealthy},
|
||||
{http.StatusOK, probe.Success},
|
||||
{-1, probe.Failure},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
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.
|
||||
const (
|
||||
Healthy Status = iota
|
||||
Unhealthy
|
||||
Success Status = iota
|
||||
Failure
|
||||
Unknown
|
||||
)
|
||||
|
||||
func (s Status) String() string {
|
||||
switch s {
|
||||
case Healthy:
|
||||
return "healthy"
|
||||
case Unhealthy:
|
||||
return "unhealthy"
|
||||
case Success:
|
||||
return "success"
|
||||
case Failure:
|
||||
return "failure"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
|
@@ -42,11 +42,11 @@ func (pr TCPProber) Probe(host string, port int) (probe.Status, error) {
|
||||
func DoTCPProbe(addr string) (probe.Status, error) {
|
||||
conn, err := net.Dial("tcp", addr)
|
||||
if err != nil {
|
||||
return probe.Unhealthy, nil
|
||||
return probe.Failure, nil
|
||||
}
|
||||
err = conn.Close()
|
||||
if err != nil {
|
||||
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
|
||||
}{
|
||||
// The probe will be filled in below. This is primarily testing that a connection is made.
|
||||
{probe.Healthy, true, false},
|
||||
{probe.Unhealthy, false, false},
|
||||
{probe.Success, true, false},
|
||||
{probe.Failure, false, false},
|
||||
}
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
Reference in New Issue
Block a user