From ea868d6f7b96680b2da279934dcd857474e922c6 Mon Sep 17 00:00:00 2001 From: Yu-Ju Hong Date: Wed, 22 Mar 2017 13:28:17 -0700 Subject: [PATCH] kuberuntime: don't override the pod IP for pods using host network --- pkg/kubelet/kuberuntime/kuberuntime_manager.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/kubelet/kuberuntime/kuberuntime_manager.go b/pkg/kubelet/kuberuntime/kuberuntime_manager.go index d55be5dd6e..13193b2471 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_manager.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_manager.go @@ -628,9 +628,13 @@ func (m *kubeGenericRuntimeManager) SyncPod(pod *v1.Pod, _ v1.PodStatus, podStat return } - // Overwrite the podIP passed in the pod status, since we just started the pod sandbox. - podIP = m.determinePodSandboxIP(pod.Namespace, pod.Name, podSandboxStatus) - glog.V(4).Infof("Determined the ip %q for pod %q after sandbox changed", podIP, format.Pod(pod)) + // If we ever allow updating a pod from non-host-network to + // host-network, we may use a stale IP. + if !kubecontainer.IsHostNetworkPod(pod) { + // Overwrite the podIP passed in the pod status, since we just started the pod sandbox. + podIP = m.determinePodSandboxIP(pod.Namespace, pod.Name, podSandboxStatus) + glog.V(4).Infof("Determined the ip %q for pod %q after sandbox changed", podIP, format.Pod(pod)) + } } // Get podSandboxConfig for containers to start.