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.
This commit is contained in:
1 parent
c720ebec02
commit
fd5e1970e1
1 file changed
+3
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user