Merge pull request #46535 from yujuhong/rm-redundant-check

Automatic merge from submit-queue

kubelet: remove a redundant check for mounting the hosts file

HostNetwork is not part of the Pod.Spec.SecurityContext in the versioned
pod. Remove the redundant check.

See https://github.com/kubernetes/kubernetes/issues/43632#issuecomment-304370330 for the explanation.
This commit is contained in:
Kubernetes Submit Queue 2017-05-30 05:40:34 -07:00 committed by GitHub
commit 2f498065d7

View File

@ -114,7 +114,7 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
// - container is not already mounting on /etc/hosts
// When the pause container is being created, its IP is still unknown. Hence, PodIP will not have been set.
// OS is not Windows
mountEtcHostsFile := (pod.Spec.SecurityContext == nil || !pod.Spec.HostNetwork) && len(podIP) > 0 && runtime.GOOS != "windows"
mountEtcHostsFile := !pod.Spec.HostNetwork && 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)
mounts := []kubecontainer.Mount{}
for _, mount := range container.VolumeMounts {