Clean up redundant DNS related kubelet codes

Signed-off-by: Zihong Zheng <zihongz@google.com>
This commit is contained in:
Zihong Zheng
2017-11-04 12:33:32 -07:00
parent 2ecb368026
commit c1a959c660
9 changed files with 101 additions and 108 deletions

View File

@@ -381,18 +381,17 @@ func (kl *Kubelet) GetPodCgroupParent(pod *v1.Pod) string {
// GenerateRunContainerOptions generates the RunContainerOptions, which can be used by
// the container runtime to set parameters for launching a container.
func (kl *Kubelet) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string) (*kubecontainer.RunContainerOptions, bool, error) {
useClusterFirstPolicy := false
func (kl *Kubelet) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string) (*kubecontainer.RunContainerOptions, error) {
opts, err := kl.containerManager.GetResources(pod, container)
if err != nil {
return nil, false, err
return nil, err
}
cgroupParent := kl.GetPodCgroupParent(pod)
opts.CgroupParent = cgroupParent
hostname, hostDomainName, err := kl.GeneratePodHostNameAndDomain(pod)
if err != nil {
return nil, false, err
return nil, err
}
opts.Hostname = hostname
podName := volumehelper.GetUniquePodName(pod)
@@ -402,19 +401,19 @@ func (kl *Kubelet) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Contai
// TODO(random-liu): Move following convert functions into pkg/kubelet/container
devices, err := kl.makeDevices(pod, container)
if err != nil {
return nil, false, err
return nil, err
}
opts.Devices = append(opts.Devices, devices...)
mounts, err := makeMounts(pod, kl.getPodDir(pod.UID), container, hostname, hostDomainName, podIP, volumes)
if err != nil {
return nil, false, err
return nil, err
}
opts.Mounts = append(opts.Mounts, mounts...)
envs, err := kl.makeEnvironmentVariables(pod, container, podIP)
if err != nil {
return nil, false, err
return nil, err
}
opts.Envs = append(opts.Envs, envs...)
@@ -429,17 +428,12 @@ func (kl *Kubelet) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Contai
}
}
opts.DNS, opts.DNSSearch, useClusterFirstPolicy, err = kl.GetClusterDNS(pod)
if err != nil {
return nil, false, err
}
// only do this check if the experimental behavior is enabled, otherwise allow it to default to false
if kl.experimentalHostUserNamespaceDefaulting {
opts.EnableHostUserNamespace = kl.enableHostUserNamespace(pod)
}
return opts, useClusterFirstPolicy, nil
return opts, nil
}
var masterServices = sets.NewString("kubernetes")