From 17a635448aaa804a26afca89cad420f9f2e6a7b6 Mon Sep 17 00:00:00 2001 From: Aldo Culquicondor Date: Mon, 11 Feb 2019 13:18:25 -0500 Subject: [PATCH] Fix cmd/kubelet/app lint issues --- cmd/kubelet/app/options/options.go | 12 +++++++----- cmd/kubelet/app/server.go | 5 ++--- hack/.golint_failures | 2 -- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/kubelet/app/options/options.go b/cmd/kubelet/app/options/options.go index f435215bd0..981e7d24b7 100644 --- a/cmd/kubelet/app/options/options.go +++ b/cmd/kubelet/app/options/options.go @@ -19,7 +19,7 @@ package options import ( "fmt" - _ "net/http/pprof" + _ "net/http/pprof" // Enable pprof HTTP handlers. "path/filepath" "runtime" "strings" @@ -47,10 +47,11 @@ import ( const defaultRootDir = "/var/lib/kubelet" +// KubeletFlags contains configuration flags for the Kubelet. // A configuration field should go in KubeletFlags instead of KubeletConfiguration if any of these are true: -// - its value will never, or cannot safely be changed during the lifetime of a node -// - its value cannot be safely shared between nodes at the same time (e.g. a hostname) -// KubeletConfiguration is intended to be shared between nodes +// - its value will never, or cannot safely be changed during the lifetime of a node, or +// - its value cannot be safely shared between nodes at the same time (e.g. a hostname); +// KubeletConfiguration is intended to be shared between nodes. // In general, please try to avoid adding flags or configuration fields, // we already have a confusingly large amount of them. type KubeletFlags struct { @@ -245,6 +246,7 @@ func NewKubeletFlags() *KubeletFlags { } } +// ValidateKubeletFlags validates Kubelet's configuration flags and returns an error if they are invalid. func ValidateKubeletFlags(f *KubeletFlags) error { // ensure that nobody sets DynamicConfigDir if the dynamic config feature gate is turned off if f.DynamicConfigDir.Provided() && !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) { @@ -336,7 +338,7 @@ func NewKubeletServer() (*KubeletServer, error) { }, nil } -// validateKubeletServer validates configuration of KubeletServer and returns an error if the input configuration is invalid +// ValidateKubeletServer validates configuration of KubeletServer and returns an error if the input configuration is invalid. func ValidateKubeletServer(s *KubeletServer) error { // please add any KubeletConfiguration validation to the kubeletconfigvalidation.ValidateKubeletConfiguration function if err := kubeletconfigvalidation.ValidateKubeletConfiguration(&s.KubeletConfiguration); err != nil { diff --git a/cmd/kubelet/app/server.go b/cmd/kubelet/app/server.go index dbe21a3b00..f7d835859b 100644 --- a/cmd/kubelet/app/server.go +++ b/cmd/kubelet/app/server.go @@ -25,7 +25,6 @@ import ( "math/rand" "net" "net/http" - _ "net/http/pprof" "net/url" "os" "path" @@ -989,7 +988,7 @@ func RunKubelet(kubeServer *options.KubeletServer, kubeDeps *kubelet.Dependencie kubeDeps.OSInterface = kubecontainer.RealOS{} } - k, err := CreateAndInitKubelet(&kubeServer.KubeletConfiguration, + k, err := createAndInitKubelet(&kubeServer.KubeletConfiguration, kubeDeps, &kubeServer.ContainerRuntimeOptions, kubeServer.ContainerRuntime, @@ -1065,7 +1064,7 @@ func startKubelet(k kubelet.Bootstrap, podCfg *config.PodConfig, kubeCfg *kubele } } -func CreateAndInitKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration, +func createAndInitKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration, kubeDeps *kubelet.Dependencies, crOptions *config.ContainerRuntimeOptions, containerRuntime string, diff --git a/hack/.golint_failures b/hack/.golint_failures index f9b01c886b..44b02ebb27 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -7,8 +7,6 @@ cmd/kubeadm/app/apis/kubeadm/v1alpha3 cmd/kubeadm/app/apis/kubeadm/v1beta1 cmd/kubeadm/app/util/config cmd/kubeadm/app/util/system -cmd/kubelet/app -cmd/kubelet/app/options pkg/apis/abac/latest pkg/apis/admission pkg/apis/admission/v1beta1