Simple code and typo fixed in in pkg/kubelet

This commit is contained in:
wangqingcan 2018-09-05 21:51:32 +08:00
parent 2c933695fa
commit b0c308f082
5 changed files with 8 additions and 9 deletions

View File

@ -177,7 +177,6 @@ pkg/kubectl/cmd/wait
pkg/kubectl/metricsutil pkg/kubectl/metricsutil
pkg/kubectl/util pkg/kubectl/util
pkg/kubectl/util/slice pkg/kubectl/util/slice
pkg/kubelet
pkg/kubelet/apis pkg/kubelet/apis
pkg/kubelet/apis/config pkg/kubelet/apis/config
pkg/kubelet/apis/config/v1beta1 pkg/kubelet/apis/config/v1beta1

View File

@ -151,7 +151,7 @@ func (kl *Kubelet) updateDefaultLabels(initialNode, existingNode *v1.Node) bool
kubeletapis.LabelArch, kubeletapis.LabelArch,
} }
var needsUpdate bool = false needsUpdate := false
if existingNode.Labels == nil { if existingNode.Labels == nil {
existingNode.Labels = make(map[string]string) existingNode.Labels = make(map[string]string)
} }

View File

@ -138,7 +138,7 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
mountEtcHostsFile := len(podIP) > 0 && runtime.GOOS != "windows" mountEtcHostsFile := len(podIP) > 0 && runtime.GOOS != "windows"
glog.V(3).Infof("container: %v/%v/%v podIP: %q creating hosts mount: %v", pod.Namespace, pod.Name, container.Name, podIP, mountEtcHostsFile) glog.V(3).Infof("container: %v/%v/%v podIP: %q creating hosts mount: %v", pod.Namespace, pod.Name, container.Name, podIP, mountEtcHostsFile)
mounts := []kubecontainer.Mount{} mounts := []kubecontainer.Mount{}
var cleanupAction func() = nil var cleanupAction func()
for i, mount := range container.VolumeMounts { for i, mount := range container.VolumeMounts {
// do not mount /etc/hosts if container is already mounting on the path // do not mount /etc/hosts if container is already mounting on the path
mountEtcHostsFile = mountEtcHostsFile && (mount.MountPath != etcHostsPath) mountEtcHostsFile = mountEtcHostsFile && (mount.MountPath != etcHostsPath)

View File

@ -318,7 +318,7 @@ func newTestKubeletWithImageList(
allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...) allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...)
} }
var prober volume.DynamicPluginProber = nil // TODO (#51147) inject mock var prober volume.DynamicPluginProber // TODO (#51147) inject mock
kubelet.volumePluginMgr, err = kubelet.volumePluginMgr, err =
NewInitializedVolumePluginMgr(kubelet, kubelet.secretManager, kubelet.configMapManager, token.NewManager(kubelet.kubeClient), allPlugins, prober) NewInitializedVolumePluginMgr(kubelet, kubelet.secretManager, kubelet.configMapManager, token.NewManager(kubelet.kubeClient), allPlugins, prober)
require.NoError(t, err, "Failed to initialize VolumePluginMgr") require.NoError(t, err, "Failed to initialize VolumePluginMgr")

View File

@ -40,8 +40,8 @@ type ReasonCache struct {
cache *lru.Cache cache *lru.Cache
} }
// Reason is the cached item in ReasonCache // ReasonItem is the cached item in ReasonCache
type reasonItem struct { type ReasonItem struct {
Err error Err error
Message string Message string
} }
@ -64,7 +64,7 @@ func (c *ReasonCache) composeKey(uid types.UID, name string) string {
func (c *ReasonCache) add(uid types.UID, name string, reason error, message string) { func (c *ReasonCache) add(uid types.UID, name string, reason error, message string) {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() defer c.lock.Unlock()
c.cache.Add(c.composeKey(uid, name), reasonItem{reason, message}) c.cache.Add(c.composeKey(uid, name), ReasonItem{reason, message})
} }
// Update updates the reason cache with the SyncPodResult. Only SyncResult with // Update updates the reason cache with the SyncPodResult. Only SyncResult with
@ -93,13 +93,13 @@ func (c *ReasonCache) Remove(uid types.UID, name string) {
// Get gets error reason from the cache. The return values are error reason, error message and // Get gets error reason from the cache. The return values are error reason, error message and
// whether an error reason is found in the cache. If no error reason is found, empty string will // whether an error reason is found in the cache. If no error reason is found, empty string will
// be returned for error reason and error message. // be returned for error reason and error message.
func (c *ReasonCache) Get(uid types.UID, name string) (*reasonItem, bool) { func (c *ReasonCache) Get(uid types.UID, name string) (*ReasonItem, bool) {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() defer c.lock.Unlock()
value, ok := c.cache.Get(c.composeKey(uid, name)) value, ok := c.cache.Get(c.composeKey(uid, name))
if !ok { if !ok {
return nil, false return nil, false
} }
info := value.(reasonItem) info := value.(ReasonItem)
return &info, true return &info, true
} }