Merge pull request #2445 from weaveworks/fix-weave-ps

Fix "weave ps" output when weave is not running
This commit is contained in:
Adam Harrison authored and GitHub committed 2016-07-28 11:30:31 +01:00
commit b06ddeb962
2 files changed
+11

No files matched your search

+6
View File
@@ -1,12 +1,15 @@
package net
import (
"errors"
"runtime"
"github.com/vishvananda/netlink"
"github.com/vishvananda/netns"
)
var ErrLinkNotFound = errors.New("Link not found")
// NB: The following function is unsafe, because:
// - It changes a network namespace (netns) of an OS thread which runs
// the function. During execution, the Go runtime might clone a new OS thread
@@ -42,6 +45,9 @@ func WithNetNSLinkUnsafe(ns netns.NsHandle, ifName string, work func(link netlin
return WithNetNSUnsafe(ns, func() error {
link, err := netlink.LinkByName(ifName)
if err != nil {
if err.Error() == errors.New("Link not found").Error() {
return ErrLinkNotFound
}
return err
}
return work(link)
+5
View File
@@ -5,7 +5,9 @@ import (
"github.com/fsouza/go-dockerclient"
"github.com/vishvananda/netlink"
"github.com/weaveworks/weave/common"
weavenet "github.com/weaveworks/weave/net"
)
func containerAddrs(args []string) error {
@@ -21,6 +23,9 @@ func containerAddrs(args []string) error {
pred, err := common.ConnectedToBridgePredicate(bridgeName)
if err != nil {
if err == weavenet.ErrLinkNotFound {
return nil
}
return err
}