mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
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:
parent
d42030170b
commit
26b6b18fad
@ -48,7 +48,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/healthz"
|
||||
"k8s.io/kubernetes/pkg/httplog"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
"k8s.io/kubernetes/pkg/kubelet/dockertools"
|
||||
"k8s.io/kubernetes/pkg/kubelet/portforward"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
@ -141,7 +140,6 @@ type AuthInterface interface {
|
||||
// For testablitiy.
|
||||
type HostInterface interface {
|
||||
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)
|
||||
GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error)
|
||||
GetPods() []*api.Pod
|
||||
@ -212,7 +210,6 @@ func (s *Server) InstallAuthFilter() {
|
||||
func (s *Server) InstallDefaultHandlers() {
|
||||
healthz.InstallHandler(s.restfulCont,
|
||||
healthz.PingHealthz,
|
||||
healthz.NamedCheck("docker", s.dockerHealthCheck),
|
||||
healthz.NamedCheck("syncloop", s.syncLoopHealthCheck),
|
||||
)
|
||||
var ws *restful.WebService
|
||||
@ -367,22 +364,6 @@ func (s *Server) error(w http.ResponseWriter, err error) {
|
||||
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.
|
||||
func (s *Server) syncLoopHealthCheck(req *http.Request) error {
|
||||
duration := s.host.ResyncInterval() * 2
|
||||
|
@ -38,8 +38,6 @@ import (
|
||||
apierrs "k8s.io/kubernetes/pkg/api/errors"
|
||||
"k8s.io/kubernetes/pkg/auth/authorizer"
|
||||
"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"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/util/httpstream"
|
||||
@ -56,7 +54,6 @@ type fakeKubelet struct {
|
||||
runningPodsFunc func() ([]*api.Pod, error)
|
||||
logFunc func(w http.ResponseWriter, req *http.Request)
|
||||
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
|
||||
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
|
||||
@ -87,10 +84,6 @@ func (fk *fakeKubelet) GetRawContainerInfo(containerName string, req *cadvisorap
|
||||
return fk.rawInfoFunc(req)
|
||||
}
|
||||
|
||||
func (fk *fakeKubelet) GetContainerRuntimeVersion() (kubecontainer.Version, error) {
|
||||
return fk.containerVersionFunc()
|
||||
}
|
||||
|
||||
func (fk *fakeKubelet) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||
return fk.machineInfoFunc()
|
||||
}
|
||||
@ -161,9 +154,6 @@ type serverTestFramework struct {
|
||||
func newServerTest() *serverTestFramework {
|
||||
fw := &serverTestFramework{}
|
||||
fw.fakeKubelet = &fakeKubelet{
|
||||
containerVersionFunc: func() (kubecontainer.Version, error) {
|
||||
return dockertools.NewVersion("1.18")
|
||||
},
|
||||
hostnameFunc: func() string {
|
||||
return "127.0.0.1"
|
||||
},
|
||||
@ -505,9 +495,6 @@ func TestServeRunInContainerWithUID(t *testing.T) {
|
||||
|
||||
func TestHealthCheck(t *testing.T) {
|
||||
fw := newServerTest()
|
||||
fw.fakeKubelet.containerVersionFunc = func() (kubecontainer.Version, error) {
|
||||
return dockertools.NewVersion("1.18")
|
||||
}
|
||||
fw.fakeKubelet.hostnameFunc = func() string {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
@ -520,13 +507,6 @@ func TestHealthCheck(t *testing.T) {
|
||||
return "fake"
|
||||
}
|
||||
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) {
|
||||
@ -714,9 +694,6 @@ func TestAuthorizationSuccess(t *testing.T) {
|
||||
|
||||
func TestSyncLoopCheck(t *testing.T) {
|
||||
fw := newServerTest()
|
||||
fw.fakeKubelet.containerVersionFunc = func() (kubecontainer.Version, error) {
|
||||
return dockertools.NewVersion("1.18")
|
||||
}
|
||||
fw.fakeKubelet.hostnameFunc = func() string {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user