From fd5e1970e17a382d3120af04ff38cb44d1528ec0 Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Wed, 14 Sep 2016 16:37:38 +0100 Subject: [PATCH] Return nil netdev if netns of container cannot be found The change applies to GetNetDevsWithPredicate. The function calls FindNetDevs which already does the same filtering. The change prevents from "container-addrs" (weaveutil) returning "unable to open X process namespace" error which happens when a container dies while the cmd is being executed. --- common/utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/utils.go b/common/utils.go index 51129500..25130ab2 100644 --- a/common/utils.go +++ b/common/utils.go @@ -132,6 +132,9 @@ func GetNetDevsWithPredicate(processID int, predicate func(link netlink.Link) bo } nsContainr, err := netns.GetFromPid(processID) if err != nil { + if os.IsNotExist(err) { + return nil, nil + } return nil, fmt.Errorf("unable to open process %d namespace: %s", processID, err) } if nsToplevel.Equal(nsContainr) {