diff --git a/pkg/health/health.go b/pkg/health/health.go index e83f5035d72..9ebd2bc34d5 100644 --- a/pkg/health/health.go +++ b/pkg/health/health.go @@ -40,7 +40,7 @@ type HealthChecker interface { // NewHealthChecker creates a new HealthChecker which supports multiple types of liveness probes. func NewHealthChecker() HealthChecker { - return &MuxHealthChecker{ + return &muxHealthChecker{ checkers: map[string]HealthChecker{ "http": &HTTPHealthChecker{ client: &http.Client{}, @@ -50,15 +50,15 @@ func NewHealthChecker() HealthChecker { } } -// MuxHealthChecker bundles multiple implementations of HealthChecker of different types. -type MuxHealthChecker struct { +// muxHealthChecker bundles multiple implementations of HealthChecker of different types. +type muxHealthChecker struct { checkers map[string]HealthChecker } // HealthCheck delegates the health-checking of the container to one of the bundled implementations. // It chooses an implementation according to container.LivenessProbe.Type. // If there is no matching health checker it returns Unknown, nil. -func (m *MuxHealthChecker) HealthCheck(currentState api.PodState, container api.Container) (Status, error) { +func (m *muxHealthChecker) HealthCheck(currentState api.PodState, container api.Container) (Status, error) { checker, ok := m.checkers[container.LivenessProbe.Type] if !ok || checker == nil { glog.Warningf("Failed to find health checker for %s %s", container.Name, container.LivenessProbe.Type) diff --git a/pkg/health/health_test.go b/pkg/health/health_test.go index a1d38a13d2d..2b17dcd709e 100644 --- a/pkg/health/health_test.go +++ b/pkg/health/health_test.go @@ -105,7 +105,7 @@ func TestMuxHealthChecker(t *testing.T) { {Healthy, "http"}, {Unknown, "ftp"}, } - mc := &MuxHealthChecker{ + mc := &muxHealthChecker{ checkers: make(map[string]HealthChecker), } hc := &HTTPHealthChecker{ diff --git a/pkg/health/http.go b/pkg/health/http.go index d9def74d0fa..0f212d21212 100644 --- a/pkg/health/http.go +++ b/pkg/health/http.go @@ -27,6 +27,7 @@ import ( ) // HTTPGetInterface is an abstract interface for testability. It abstracts the interface of http.Client.Get. +// This is exported because some other packages may want to do direct HTTP checks. type HTTPGetInterface interface { Get(url string) (*http.Response, error) } @@ -78,6 +79,7 @@ func formatURL(host string, port int, path string) string { // If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Healthy. // If the HTTP response code is unsuccessful, it returns Unhealthy. // It returns Unknown and err if the HTTP communication itself fails. +// This is exported because some other packages may want to do direct HTTP checks. func DoHTTPCheck(url string, client HTTPGetInterface) (Status, error) { res, err := client.Get(url) if err != nil { diff --git a/pkg/health/tcp.go b/pkg/health/tcp.go index fef200ac292..7818c511bf0 100644 --- a/pkg/health/tcp.go +++ b/pkg/health/tcp.go @@ -61,6 +61,7 @@ func getTCPAddrParts(currentState api.PodState, container api.Container) (string // DoTCPCheck checks that a TCP socket to the address can be opened. // If the socket can be opened, it returns Healthy. // If the socket fails to open, it returns Unhealthy. +// This is exported because some other packages may want to do direct TCP checks. func DoTCPCheck(addr string) (Status, error) { conn, err := net.Dial("tcp", addr) if err != nil {