diff --git a/pkg/kubelet/dockershim/docker_sandbox.go b/pkg/kubelet/dockershim/docker_sandbox.go index 40689d6ff52..27981349c6f 100644 --- a/pkg/kubelet/dockershim/docker_sandbox.go +++ b/pkg/kubelet/dockershim/docker_sandbox.go @@ -178,9 +178,6 @@ func (ds *dockerService) getIPFromPlugin(sandbox *dockertypes.ContainerJSON) (st return "", err } msg := fmt.Sprintf("Couldn't find network status for %s/%s through plugin", metadata.Namespace, metadata.Name) - if sharesHostNetwork(sandbox) { - return "", fmt.Errorf("%v: not responsible for host-network sandboxes", msg) - } cID := kubecontainer.BuildContainerID(runtimeName, sandbox.ID) networkStatus, err := ds.networkPlugin.GetPodNetworkStatus(metadata.Namespace, metadata.Name, cID) if err != nil { @@ -202,6 +199,11 @@ func (ds *dockerService) getIP(sandbox *dockertypes.ContainerJSON) (string, erro if sandbox.NetworkSettings == nil { return "", nil } + if sharesHostNetwork(sandbox) { + // For sandboxes using host network, the shim is not responsible for + // reporting the IP. + return "", nil + } if IP, err := ds.getIPFromPlugin(sandbox); err != nil { glog.Warningf("%v", err) } else if IP != "" { diff --git a/pkg/kubelet/kuberuntime/kuberuntime_sandbox.go b/pkg/kubelet/kuberuntime/kuberuntime_sandbox.go index ec9ecd1d64d..52f54a8d0b9 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_sandbox.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_sandbox.go @@ -198,7 +198,9 @@ func (m *kubeGenericRuntimeManager) determinePodSandboxIP(podNamespace, podName return "" } ip := podSandbox.Network.Ip - if net.ParseIP(ip) == nil { + if len(ip) != 0 && net.ParseIP(ip) == nil { + // ip could be an empty string if runtime is not responsible for the + // IP (e.g., host networking). glog.Warningf("Pod Sandbox reported an unparseable IP %v", ip) return "" }