Fix "weave ps" output when weave is not running

The #2418 has changed a behaviour of "weave ps" which outputs
"Link not found" in the case of weave not running. The previous
behaviour was to output an empty line.
This commit is contained in:
Martynas Pumputis committed 2016-07-14 15:15:14 +01:00
1 parent acdd739deb
commit fd0a7efa23
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
}