diff --git a/pkg/kubelet/dockershim/docker_streaming.go b/pkg/kubelet/dockershim/docker_streaming.go index cf599d8a9fe..4c4b74185ab 100644 --- a/pkg/kubelet/dockershim/docker_streaming.go +++ b/pkg/kubelet/dockershim/docker_streaming.go @@ -159,8 +159,8 @@ func attachContainer(client libdocker.Interface, containerID string, stdin io.Re return client.AttachToContainer(containerID, opts, sopts) } -func portForward(client libdocker.Interface, podInfraContainerID string, port int32, stream io.ReadWriteCloser) error { - container, err := client.InspectContainer(podInfraContainerID) +func portForward(client libdocker.Interface, podSandboxID string, port int32, stream io.ReadWriteCloser) error { + container, err := client.InspectContainer(podSandboxID) if err != nil { return err } diff --git a/pkg/kubelet/dockershim/security_context.go b/pkg/kubelet/dockershim/security_context.go index 95a730dc03b..e51f84da094 100644 --- a/pkg/kubelet/dockershim/security_context.go +++ b/pkg/kubelet/dockershim/security_context.go @@ -54,7 +54,7 @@ func applySandboxSecurityContext(lc *runtimeapi.LinuxPodSandboxConfig, config *d } // applyContainerSecurityContext updates docker container options according to security context. -func applyContainerSecurityContext(lc *runtimeapi.LinuxContainerConfig, sandboxID string, config *dockercontainer.Config, hc *dockercontainer.HostConfig, separator rune) error { +func applyContainerSecurityContext(lc *runtimeapi.LinuxContainerConfig, podSandboxID string, config *dockercontainer.Config, hc *dockercontainer.HostConfig, separator rune) error { if lc == nil { return nil } @@ -63,7 +63,7 @@ func applyContainerSecurityContext(lc *runtimeapi.LinuxContainerConfig, sandboxI if err := modifyHostConfig(lc.SecurityContext, hc, separator); err != nil { return err } - modifyContainerNamespaceOptions(lc.SecurityContext.GetNamespaceOptions(), sandboxID, hc) + modifyContainerNamespaceOptions(lc.SecurityContext.GetNamespaceOptions(), podSandboxID, hc) return nil } @@ -127,14 +127,14 @@ func modifySandboxNamespaceOptions(nsOpts *runtimeapi.NamespaceOption, hostConfi } // modifyContainerNamespaceOptions apply namespace options for container -func modifyContainerNamespaceOptions(nsOpts *runtimeapi.NamespaceOption, sandboxID string, hostConfig *dockercontainer.HostConfig) { +func modifyContainerNamespaceOptions(nsOpts *runtimeapi.NamespaceOption, podSandboxID string, hostConfig *dockercontainer.HostConfig) { hostNetwork := false if nsOpts != nil { hostNetwork = nsOpts.HostNetwork } - hostConfig.PidMode = dockercontainer.PidMode(fmt.Sprintf("container:%v", sandboxID)) + hostConfig.PidMode = dockercontainer.PidMode(fmt.Sprintf("container:%v", podSandboxID)) modifyCommonNamespaceOptions(nsOpts, hostConfig) - modifyHostNetworkOptionForContainer(hostNetwork, sandboxID, hostConfig) + modifyHostNetworkOptionForContainer(hostNetwork, podSandboxID, hostConfig) } // modifyCommonNamespaceOptions apply common namespace options for sandbox and container @@ -172,8 +172,8 @@ func modifyHostNetworkOptionForSandbox(hostNetwork bool, network *knetwork.Plugi } // modifyHostNetworkOptionForContainer applies NetworkMode/UTSMode to container's dockercontainer.HostConfig. -func modifyHostNetworkOptionForContainer(hostNetwork bool, sandboxID string, hc *dockercontainer.HostConfig) { - sandboxNSMode := fmt.Sprintf("container:%v", sandboxID) +func modifyHostNetworkOptionForContainer(hostNetwork bool, podSandboxID string, hc *dockercontainer.HostConfig) { + sandboxNSMode := fmt.Sprintf("container:%v", podSandboxID) hc.NetworkMode = dockercontainer.NetworkMode(sandboxNSMode) hc.IpcMode = dockercontainer.IpcMode(sandboxNSMode) hc.UTSMode = "" diff --git a/pkg/kubelet/network/cni/cni.go b/pkg/kubelet/network/cni/cni.go index 02c3719c092..33301f98292 100644 --- a/pkg/kubelet/network/cni/cni.go +++ b/pkg/kubelet/network/cni/cni.go @@ -280,8 +280,8 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin return &network.PodNetworkStatus{IP: ip}, nil } -func (plugin *cniNetworkPlugin) addToNetwork(network *cniNetwork, podName string, podNamespace string, podInfraContainerID kubecontainer.ContainerID, podNetnsPath string) (cnitypes.Result, error) { - rt, err := plugin.buildCNIRuntimeConf(podName, podNamespace, podInfraContainerID, podNetnsPath) +func (plugin *cniNetworkPlugin) addToNetwork(network *cniNetwork, podName string, podNamespace string, podSandboxID kubecontainer.ContainerID, podNetnsPath string) (cnitypes.Result, error) { + rt, err := plugin.buildCNIRuntimeConf(podName, podNamespace, podSandboxID, podNetnsPath) if err != nil { glog.Errorf("Error adding network when building cni runtime conf: %v", err) return nil, err @@ -298,8 +298,8 @@ func (plugin *cniNetworkPlugin) addToNetwork(network *cniNetwork, podName string return res, nil } -func (plugin *cniNetworkPlugin) deleteFromNetwork(network *cniNetwork, podName string, podNamespace string, podInfraContainerID kubecontainer.ContainerID, podNetnsPath string) error { - rt, err := plugin.buildCNIRuntimeConf(podName, podNamespace, podInfraContainerID, podNetnsPath) +func (plugin *cniNetworkPlugin) deleteFromNetwork(network *cniNetwork, podName string, podNamespace string, podSandboxID kubecontainer.ContainerID, podNetnsPath string) error { + rt, err := plugin.buildCNIRuntimeConf(podName, podNamespace, podSandboxID, podNetnsPath) if err != nil { glog.Errorf("Error deleting network when building cni runtime conf: %v", err) return err @@ -315,25 +315,25 @@ func (plugin *cniNetworkPlugin) deleteFromNetwork(network *cniNetwork, podName s return nil } -func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string, podInfraContainerID kubecontainer.ContainerID, podNetnsPath string) (*libcni.RuntimeConf, error) { +func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string, podSandboxID kubecontainer.ContainerID, podNetnsPath string) (*libcni.RuntimeConf, error) { glog.V(4).Infof("Got netns path %v", podNetnsPath) glog.V(4).Infof("Using netns path %v", podNs) rt := &libcni.RuntimeConf{ - ContainerID: podInfraContainerID.ID, + ContainerID: podSandboxID.ID, NetNS: podNetnsPath, IfName: network.DefaultInterfaceName, Args: [][2]string{ {"IgnoreUnknown", "1"}, {"K8S_POD_NAMESPACE", podNs}, {"K8S_POD_NAME", podName}, - {"K8S_POD_INFRA_CONTAINER_ID", podInfraContainerID.ID}, + {"K8S_POD_INFRA_CONTAINER_ID", podSandboxID.ID}, }, } // port mappings are a cni capability-based args, rather than parameters // to a specific plugin - portMappings, err := plugin.host.GetPodPortMappings(podInfraContainerID.ID) + portMappings, err := plugin.host.GetPodPortMappings(podSandboxID.ID) if err != nil { return nil, fmt.Errorf("could not retrieve port mappings: %v", err) } diff --git a/pkg/kubelet/network/plugins.go b/pkg/kubelet/network/plugins.go index 08c6ef2d49e..ac35756d16e 100644 --- a/pkg/kubelet/network/plugins.go +++ b/pkg/kubelet/network/plugins.go @@ -63,16 +63,13 @@ type NetworkPlugin interface { // SetUpPod is the method called after the infra container of // the pod has been created but before the other containers of the // pod are launched. - // TODO: rename podInfraContainerID to sandboxID - SetUpPod(namespace string, name string, podInfraContainerID kubecontainer.ContainerID, annotations map[string]string) error + SetUpPod(namespace string, name string, podSandboxID kubecontainer.ContainerID, annotations map[string]string) error // TearDownPod is the method called before a pod's infra container will be deleted - // TODO: rename podInfraContainerID to sandboxID - TearDownPod(namespace string, name string, podInfraContainerID kubecontainer.ContainerID) error + TearDownPod(namespace string, name string, podSandboxID kubecontainer.ContainerID) error // GetPodNetworkStatus is the method called to obtain the ipv4 or ipv6 addresses of the container - // TODO: rename podInfraContainerID to sandboxID - GetPodNetworkStatus(namespace string, name string, podInfraContainerID kubecontainer.ContainerID) (*PodNetworkStatus, error) + GetPodNetworkStatus(namespace string, name string, podSandboxID kubecontainer.ContainerID) (*PodNetworkStatus, error) // Status returns error if the network plugin is in error state Status() error @@ -136,7 +133,7 @@ type Host interface { } // NamespaceGetter is an interface to retrieve namespace information for a given -// sandboxID. Typically implemented by runtime shims that are closely coupled to +// podSandboxID. Typically implemented by runtime shims that are closely coupled to // CNI plugin wrappers like kubenet. type NamespaceGetter interface { // GetNetNS returns network namespace information for the given containerID. @@ -146,7 +143,7 @@ type NamespaceGetter interface { } // PortMappingGetter is an interface to retrieve port mapping information for a given -// sandboxID. Typically implemented by runtime shims that are closely coupled to +// podSandboxID. Typically implemented by runtime shims that are closely coupled to // CNI plugin wrappers like kubenet. type PortMappingGetter interface { // GetPodPortMappings returns sandbox port mappings information.