From fe7795746193c1bdbffe7ce7fc7ff223de3787ba Mon Sep 17 00:00:00 2001 From: Aaron Levy Date: Wed, 26 Apr 2017 19:23:03 -0700 Subject: [PATCH] Skip inspecting pod network if unknown namespace --- pkg/kubelet/network/cni/cni.go | 3 +++ pkg/kubelet/network/kubenet/kubenet_linux.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkg/kubelet/network/cni/cni.go b/pkg/kubelet/network/cni/cni.go index 55cedf358e3..9a4fed27f7c 100644 --- a/pkg/kubelet/network/cni/cni.go +++ b/pkg/kubelet/network/cni/cni.go @@ -266,6 +266,9 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin if err != nil { return nil, fmt.Errorf("CNI failed to retrieve network namespace path: %v", err) } + if netnsPath == "" { + return nil, fmt.Errorf("Cannot find the network namespace, skipping pod network status for container %q", id) + } ip, err := network.GetPodIP(plugin.execer, plugin.nsenterPath, netnsPath, network.DefaultInterfaceName) if err != nil { diff --git a/pkg/kubelet/network/kubenet/kubenet_linux.go b/pkg/kubelet/network/kubenet/kubenet_linux.go index 122c5e61659..86224c3e46e 100644 --- a/pkg/kubelet/network/kubenet/kubenet_linux.go +++ b/pkg/kubelet/network/kubenet/kubenet_linux.go @@ -558,6 +558,9 @@ func (plugin *kubenetNetworkPlugin) GetPodNetworkStatus(namespace string, name s if err != nil { return nil, fmt.Errorf("Kubenet failed to retrieve network namespace path: %v", err) } + if netnsPath == "" { + return nil, fmt.Errorf("Cannot find the network namespace, skipping pod network status for container %q", id) + } ip, err := network.GetPodIP(plugin.execer, plugin.nsenterPath, netnsPath, network.DefaultInterfaceName) if err != nil { return nil, err