From 0c4974a31a9b7b49314d8aefa15d63cdebc7c059 Mon Sep 17 00:00:00 2001 From: yuexiao-wang Date: Sun, 9 Oct 2016 17:24:50 +0800 Subject: [PATCH] Fix some logs and commend informations for healthz Signed-off-by: yuexiao-wang --- pkg/healthz/healthz.go | 8 ++++---- pkg/healthz/healthz_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/healthz/healthz.go b/pkg/healthz/healthz.go index b71797d7531..a1e339fa4e4 100644 --- a/pkg/healthz/healthz.go +++ b/pkg/healthz/healthz.go @@ -23,7 +23,7 @@ import ( "sync" ) -// HealthzChecker is a named healthz check. +// HealthzChecker is a named healthz checker. type HealthzChecker interface { Name() string Check(req *http.Request) error @@ -41,7 +41,7 @@ func DefaultHealthz(checks ...HealthzChecker) { // PingHealthz returns true automatically when checked var PingHealthz HealthzChecker = ping{} -// ping implements the simplest possible health checker. +// ping implements the simplest possible healthz checker. type ping struct{} func (ping) Name() string { @@ -53,7 +53,7 @@ func (ping) Check(_ *http.Request) error { return nil } -// NamedCheck returns a health checker for the given name and function. +// NamedCheck returns a healthz checker for the given name and function. func NamedCheck(name string, check func(r *http.Request) error) HealthzChecker { return &healthzCheck{name, check} } @@ -125,7 +125,7 @@ func adaptCheckToHandler(c func(r *http.Request) error) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { err := c(r) if err != nil { - http.Error(w, fmt.Sprintf("Internal server error: %v", err), http.StatusInternalServerError) + http.Error(w, fmt.Sprintf("internal server error: %v", err), http.StatusInternalServerError) } else { fmt.Fprint(w, "ok") } diff --git a/pkg/healthz/healthz_test.go b/pkg/healthz/healthz_test.go index 190ea5441ca..3cd9767b4d4 100644 --- a/pkg/healthz/healthz_test.go +++ b/pkg/healthz/healthz_test.go @@ -29,15 +29,15 @@ func TestInstallHandler(t *testing.T) { InstallHandler(mux) req, err := http.NewRequest("GET", "http://example.com/healthz", nil) if err != nil { - t.Fatalf("Unexpected error: %v", err) + t.Fatalf("unexpected error: %v", err) } w := httptest.NewRecorder() mux.ServeHTTP(w, req) if w.Code != http.StatusOK { - t.Errorf("Expected %v, got %v", http.StatusOK, w.Code) + t.Errorf("expected %v, got %v", http.StatusOK, w.Code) } if w.Body.String() != "ok" { - t.Errorf("Expected %v, got %v", "ok", w.Body.String()) + t.Errorf("expected %v, got %v", "ok", w.Body.String()) } } @@ -53,7 +53,7 @@ func TestMulitipleChecks(t *testing.T) { {"/healthz", "ok", http.StatusOK, false}, {"/healthz?verbose", "[+]ping ok\n[-]bad failed: this will fail\nhealthz check failed\n", http.StatusInternalServerError, true}, {"/healthz/ping", "ok", http.StatusOK, true}, - {"/healthz/bad", "Internal server error: this will fail\n", http.StatusInternalServerError, true}, + {"/healthz/bad", "internal server error: this will fail\n", http.StatusInternalServerError, true}, {"/healthz", "[+]ping ok\n[-]bad failed: this will fail\nhealthz check failed\n", http.StatusInternalServerError, true}, }