mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Fixes golint errors in pkg/kubelet
This commit is contained in:
parent
c6b27bb87d
commit
edac5ce0b8
@ -27,6 +27,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
|
@ -25,14 +25,17 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// HealthCheckStatus is an enum type which describes a status of health check.
|
||||||
type HealthCheckStatus int
|
type HealthCheckStatus int
|
||||||
|
|
||||||
|
// These are the valid values of HealthCheckStatus.
|
||||||
const (
|
const (
|
||||||
CheckHealthy HealthCheckStatus = 0
|
CheckHealthy HealthCheckStatus = 0
|
||||||
CheckUnhealthy HealthCheckStatus = 1
|
CheckUnhealthy HealthCheckStatus = 1
|
||||||
CheckUnknown HealthCheckStatus = 2
|
CheckUnknown HealthCheckStatus = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// HealthChecker hides implementation details of checking health of containers.
|
||||||
type HealthChecker interface {
|
type HealthChecker interface {
|
||||||
HealthCheck(container api.Container) (HealthCheckStatus, error)
|
HealthCheck(container api.Container) (HealthCheckStatus, error)
|
||||||
}
|
}
|
||||||
@ -57,6 +60,8 @@ type MuxHealthChecker struct {
|
|||||||
checkers map[string]HealthChecker
|
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.
|
||||||
func (m *MuxHealthChecker) HealthCheck(container api.Container) (HealthCheckStatus, error) {
|
func (m *MuxHealthChecker) HealthCheck(container api.Container) (HealthCheckStatus, error) {
|
||||||
checker, ok := m.checkers[container.LivenessProbe.Type]
|
checker, ok := m.checkers[container.LivenessProbe.Type]
|
||||||
if !ok || checker == nil {
|
if !ok || checker == nil {
|
||||||
@ -81,6 +86,7 @@ func (h *HTTPHealthChecker) findPort(container api.Container, portName string) i
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HealthCheck checks if the container is healthy by trying sending HTTP Get requests to the container.
|
||||||
func (h *HTTPHealthChecker) HealthCheck(container api.Container) (HealthCheckStatus, error) {
|
func (h *HTTPHealthChecker) HealthCheck(container api.Container) (HealthCheckStatus, error) {
|
||||||
params := container.LivenessProbe.HTTPGet
|
params := container.LivenessProbe.HTTPGet
|
||||||
if params == nil {
|
if params == nil {
|
||||||
|
@ -34,7 +34,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
@ -145,7 +144,7 @@ func (kl *Kubelet) RunKubelet(dockerEndpoint, configPath, manifestURL, etcdServe
|
|||||||
}
|
}
|
||||||
if address != "" {
|
if address != "" {
|
||||||
glog.Infof("Starting to listen on %s:%d", address, port)
|
glog.Infof("Starting to listen on %s:%d", address, port)
|
||||||
handler := KubeletServer{
|
handler := Server{
|
||||||
Kubelet: kl,
|
Kubelet: kl,
|
||||||
UpdateChannel: updateChannel,
|
UpdateChannel: updateChannel,
|
||||||
DelegateHandler: http.DefaultServeMux,
|
DelegateHandler: http.DefaultServeMux,
|
||||||
|
@ -31,8 +31,8 @@ import (
|
|||||||
"gopkg.in/v1/yaml"
|
"gopkg.in/v1/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KubeletServer is a http.Handler which exposes kubelet functionality over HTTP.
|
// Server is a http.Handler which exposes kubelet functionality over HTTP.
|
||||||
type KubeletServer struct {
|
type Server struct {
|
||||||
Kubelet kubeletInterface
|
Kubelet kubeletInterface
|
||||||
UpdateChannel chan<- manifestUpdate
|
UpdateChannel chan<- manifestUpdate
|
||||||
DelegateHandler http.Handler
|
DelegateHandler http.Handler
|
||||||
@ -46,11 +46,11 @@ type kubeletInterface interface {
|
|||||||
GetPodInfo(name string) (api.PodInfo, error)
|
GetPodInfo(name string) (api.PodInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *KubeletServer) error(w http.ResponseWriter, err error) {
|
func (s *Server) error(w http.ResponseWriter, err error) {
|
||||||
http.Error(w, fmt.Sprintf("Internal Error: %v", err), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("Internal Error: %v", err), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *KubeletServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
defer apiserver.MakeLogged(req, &w).Log()
|
defer apiserver.MakeLogged(req, &w).Log()
|
||||||
|
|
||||||
u, err := url.ParseRequestURI(req.RequestURI)
|
u, err := url.ParseRequestURI(req.RequestURI)
|
||||||
@ -110,7 +110,7 @@ func (s *KubeletServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *KubeletServer) serveStats(w http.ResponseWriter, req *http.Request) {
|
func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
|
||||||
// /stats/<podid>/<containerName>
|
// /stats/<podid>/<containerName>
|
||||||
components := strings.Split(strings.TrimPrefix(path.Clean(req.URL.Path), "/"), "/")
|
components := strings.Split(strings.TrimPrefix(path.Clean(req.URL.Path), "/"), "/")
|
||||||
var stats *api.ContainerStats
|
var stats *api.ContainerStats
|
||||||
|
Loading…
Reference in New Issue
Block a user