Remove docker health handler from kubelet /healthz

Docker's health is checked separately from kubelet by the processing monitoring
tool (e.g., supervisord). kubelet should not be killed when docker is down.
This change removes the docker health handler from kubelet's /healthz handler.
This commit is contained in:
Yu-Ju Hong 2015-11-24 17:22:55 -08:00
parent d42030170b
commit 26b6b18fad
2 changed files with 0 additions and 42 deletions

View File

@ -48,7 +48,6 @@ import (
"k8s.io/kubernetes/pkg/healthz" "k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/httplog" "k8s.io/kubernetes/pkg/httplog"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/kubelet/portforward" "k8s.io/kubernetes/pkg/kubelet/portforward"
"k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
@ -141,7 +140,6 @@ type AuthInterface interface {
// For testablitiy. // For testablitiy.
type HostInterface interface { type HostInterface interface {
GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error)
GetContainerRuntimeVersion() (kubecontainer.Version, error)
GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorapi.ContainerInfo, error) GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorapi.ContainerInfo, error)
GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error)
GetPods() []*api.Pod GetPods() []*api.Pod
@ -212,7 +210,6 @@ func (s *Server) InstallAuthFilter() {
func (s *Server) InstallDefaultHandlers() { func (s *Server) InstallDefaultHandlers() {
healthz.InstallHandler(s.restfulCont, healthz.InstallHandler(s.restfulCont,
healthz.PingHealthz, healthz.PingHealthz,
healthz.NamedCheck("docker", s.dockerHealthCheck),
healthz.NamedCheck("syncloop", s.syncLoopHealthCheck), healthz.NamedCheck("syncloop", s.syncLoopHealthCheck),
) )
var ws *restful.WebService var ws *restful.WebService
@ -367,22 +364,6 @@ func (s *Server) error(w http.ResponseWriter, err error) {
http.Error(w, msg, http.StatusInternalServerError) http.Error(w, msg, http.StatusInternalServerError)
} }
func (s *Server) dockerHealthCheck(req *http.Request) error {
version, err := s.host.GetContainerRuntimeVersion()
if err != nil {
return errors.New("unknown Docker version")
}
// Verify the docker version.
result, err := version.Compare(dockertools.MinimumDockerAPIVersion)
if err != nil {
return err
}
if result < 0 {
return fmt.Errorf("Docker version is too old: %q", version.String())
}
return nil
}
// Checks if kubelet's sync loop that updates containers is working. // Checks if kubelet's sync loop that updates containers is working.
func (s *Server) syncLoopHealthCheck(req *http.Request) error { func (s *Server) syncLoopHealthCheck(req *http.Request) error {
duration := s.host.ResyncInterval() * 2 duration := s.host.ResyncInterval() * 2

View File

@ -38,8 +38,6 @@ import (
apierrs "k8s.io/kubernetes/pkg/api/errors" apierrs "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/auth/authorizer" "k8s.io/kubernetes/pkg/auth/authorizer"
"k8s.io/kubernetes/pkg/auth/user" "k8s.io/kubernetes/pkg/auth/user"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types" kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/httpstream" "k8s.io/kubernetes/pkg/util/httpstream"
@ -56,7 +54,6 @@ type fakeKubelet struct {
runningPodsFunc func() ([]*api.Pod, error) runningPodsFunc func() ([]*api.Pod, error)
logFunc func(w http.ResponseWriter, req *http.Request) logFunc func(w http.ResponseWriter, req *http.Request)
runFunc func(podFullName string, uid types.UID, containerName string, cmd []string) ([]byte, error) runFunc func(podFullName string, uid types.UID, containerName string, cmd []string) ([]byte, error)
containerVersionFunc func() (kubecontainer.Version, error)
execFunc func(pod string, uid types.UID, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool) error execFunc func(pod string, uid types.UID, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool) error
attachFunc func(pod string, uid types.UID, container string, in io.Reader, out, err io.WriteCloser, tty bool) error attachFunc func(pod string, uid types.UID, container string, in io.Reader, out, err io.WriteCloser, tty bool) error
portForwardFunc func(name string, uid types.UID, port uint16, stream io.ReadWriteCloser) error portForwardFunc func(name string, uid types.UID, port uint16, stream io.ReadWriteCloser) error
@ -87,10 +84,6 @@ func (fk *fakeKubelet) GetRawContainerInfo(containerName string, req *cadvisorap
return fk.rawInfoFunc(req) return fk.rawInfoFunc(req)
} }
func (fk *fakeKubelet) GetContainerRuntimeVersion() (kubecontainer.Version, error) {
return fk.containerVersionFunc()
}
func (fk *fakeKubelet) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error) { func (fk *fakeKubelet) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error) {
return fk.machineInfoFunc() return fk.machineInfoFunc()
} }
@ -161,9 +154,6 @@ type serverTestFramework struct {
func newServerTest() *serverTestFramework { func newServerTest() *serverTestFramework {
fw := &serverTestFramework{} fw := &serverTestFramework{}
fw.fakeKubelet = &fakeKubelet{ fw.fakeKubelet = &fakeKubelet{
containerVersionFunc: func() (kubecontainer.Version, error) {
return dockertools.NewVersion("1.18")
},
hostnameFunc: func() string { hostnameFunc: func() string {
return "127.0.0.1" return "127.0.0.1"
}, },
@ -505,9 +495,6 @@ func TestServeRunInContainerWithUID(t *testing.T) {
func TestHealthCheck(t *testing.T) { func TestHealthCheck(t *testing.T) {
fw := newServerTest() fw := newServerTest()
fw.fakeKubelet.containerVersionFunc = func() (kubecontainer.Version, error) {
return dockertools.NewVersion("1.18")
}
fw.fakeKubelet.hostnameFunc = func() string { fw.fakeKubelet.hostnameFunc = func() string {
return "127.0.0.1" return "127.0.0.1"
} }
@ -520,13 +507,6 @@ func TestHealthCheck(t *testing.T) {
return "fake" return "fake"
} }
assertHealthIsOk(t, fw.testHTTPServer.URL+"/healthz") assertHealthIsOk(t, fw.testHTTPServer.URL+"/healthz")
//Test with old container runtime version
fw.fakeKubelet.containerVersionFunc = func() (kubecontainer.Version, error) {
return dockertools.NewVersion("1.16")
}
assertHealthFails(t, fw.testHTTPServer.URL+"/healthz", http.StatusInternalServerError)
} }
func assertHealthFails(t *testing.T, httpURL string, expectedErrorCode int) { func assertHealthFails(t *testing.T, httpURL string, expectedErrorCode int) {
@ -714,9 +694,6 @@ func TestAuthorizationSuccess(t *testing.T) {
func TestSyncLoopCheck(t *testing.T) { func TestSyncLoopCheck(t *testing.T) {
fw := newServerTest() fw := newServerTest()
fw.fakeKubelet.containerVersionFunc = func() (kubecontainer.Version, error) {
return dockertools.NewVersion("1.18")
}
fw.fakeKubelet.hostnameFunc = func() string { fw.fakeKubelet.hostnameFunc = func() string {
return "127.0.0.1" return "127.0.0.1"
} }