From 206764128403bfb133f6b894b718bfe22c9cf051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Wed, 7 Oct 2015 10:21:33 +1100 Subject: [PATCH 1/2] hairpin: include command output when unable to query container's interface --- pkg/kubelet/network/hairpin/hairpin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kubelet/network/hairpin/hairpin.go b/pkg/kubelet/network/hairpin/hairpin.go index 508f04ad22f..14586f61dd4 100644 --- a/pkg/kubelet/network/hairpin/hairpin.go +++ b/pkg/kubelet/network/hairpin/hairpin.go @@ -64,7 +64,7 @@ func findPairInterfaceOfContainerInterface(e exec.Interface, containerPid int, c // Get container's interface index output, err := e.Command(nsenterPath, "-t", fmt.Sprintf("%d", containerPid), "-n", "-F", "--", ethtoolPath, "--statistics", containerInterfaceName).CombinedOutput() if err != nil { - return "", fmt.Errorf("Unable to query interface %s of container %d: %v", containerInterfaceName, containerPid, err) + return "", fmt.Errorf("Unable to query interface %s of container %d: %v: %s", containerInterfaceName, containerPid, err, string(output)) } // look for peer_ifindex match := ethtoolOutputRegex.FindSubmatch(output) From 0375743241eca69db9a0e2f54ae125575a62fa9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Wed, 7 Oct 2015 11:26:01 +1100 Subject: [PATCH 2/2] hairpin: unless the pod is on the host's network --- pkg/kubelet/dockertools/manager.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/kubelet/dockertools/manager.go b/pkg/kubelet/dockertools/manager.go index 94e1126d7f5..0a0a6dfb849 100644 --- a/pkg/kubelet/dockertools/manager.go +++ b/pkg/kubelet/dockertools/manager.go @@ -1882,14 +1882,16 @@ func (dm *DockerManager) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, pod return err } - // Setup the host interface (FIXME: move to networkPlugin when ready) + // Setup the host interface unless the pod is on the host's network (FIXME: move to networkPlugin when ready) podInfraContainer, err := dm.client.InspectContainer(string(podInfraContainerID)) if err != nil { glog.Errorf("Failed to inspect pod infra container: %v; Skipping pod %q", err, podFullName) return err } - if err = hairpin.SetUpContainer(podInfraContainer.State.Pid, "eth0"); err != nil { - glog.Warningf("Hairpin setup failed for pod %q: %v", podFullName, err) + if !(pod.Spec.SecurityContext != nil && pod.Spec.SecurityContext.HostNetwork) { + if err = hairpin.SetUpContainer(podInfraContainer.State.Pid, "eth0"); err != nil { + glog.Warningf("Hairpin setup failed for pod %q: %v", podFullName, err) + } } if podDependsOnPodIP(pod) { // Find the pod IP after starting the infra container in order to expose