From 43b4f4120252d82303c65890f291a26377df38ab Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Thu, 5 Mar 2015 14:44:22 -0800 Subject: [PATCH] Allow /healthz check from localhost --- pkg/kubelet/server.go | 12 +++++++----- pkg/kubelet/server_test.go | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/kubelet/server.go b/pkg/kubelet/server.go index 88f444c2708..7433d9d7ab6 100644 --- a/pkg/kubelet/server.go +++ b/pkg/kubelet/server.go @@ -165,11 +165,13 @@ func (s *Server) handleHealthz(w http.ResponseWriter, req *http.Request) { // Check that the hostname known by the master matches the hostname // the kubelet knows - hostname := s.host.GetHostname() - if masterHostname != hostname { - s.error(w, errors.New("Kubelet hostname \""+hostname+"\" does not match the hostname expected by the master \""+masterHostname+"\"")) - return - } + /* + hostname := s.host.GetHostname() + if masterHostname != hostname { + s.error(w, errors.New("Kubelet hostname \""+hostname+"\" does not match the hostname expected by the master \""+masterHostname+"\"")) + return + } + */ w.Write([]byte("ok")) } diff --git a/pkg/kubelet/server_test.go b/pkg/kubelet/server_test.go index b186e1be209..9816bed9fb1 100644 --- a/pkg/kubelet/server_test.go +++ b/pkg/kubelet/server_test.go @@ -483,8 +483,8 @@ func TestHealthCheck(t *testing.T) { t.Fatalf("Got error GETing: %v", err) } defer resp.Body.Close() - if resp.StatusCode != http.StatusInternalServerError { - t.Errorf("expected status code %d, got %d", http.StatusInternalServerError, resp.StatusCode) + if resp.StatusCode != http.StatusOK { + t.Errorf("expected status code %d, got %d", http.StatusOK, resp.StatusCode) } //Test with old docker version @@ -498,7 +498,7 @@ func TestHealthCheck(t *testing.T) { } defer resp.Body.Close() if resp.StatusCode != http.StatusInternalServerError { - t.Errorf("expected status code %d, got %d", http.StatusOK, resp.StatusCode) + t.Errorf("expected status code %d, got %d", http.StatusInternalServerError, resp.StatusCode) } }