Merge pull request #3381 from weaveworks/issue-3133
Monitor and throw error message in the logs if Weave bridge interface is down Fix #3133
This commit is contained in:
1 file changed
+26
@@ -5,6 +5,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
"github.com/coreos/go-iptables/iptables"
|
||||
"github.com/pkg/errors"
|
||||
@@ -283,6 +284,10 @@ func EnsureBridge(procPath string, config *BridgeConfig, log *logrus.Logger, ips
|
||||
return bridgeType, err
|
||||
}
|
||||
|
||||
if err := monitorInterface(config.WeaveBridgeName, log); err != nil {
|
||||
return bridgeType, err
|
||||
}
|
||||
|
||||
if err := configureARPCache(procPath, config.WeaveBridgeName); err != nil {
|
||||
return bridgeType, errors.Wrapf(err, "configuring ARP cache on bridge %q", config.WeaveBridgeName)
|
||||
}
|
||||
@@ -609,3 +614,24 @@ func reexpose(config *BridgeConfig, log *logrus.Logger) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func monitorInterface(ifaceName string, log *logrus.Logger) error {
|
||||
_, err := netlink.LinkByName(ifaceName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to find link %q: %s", ifaceName, err)
|
||||
}
|
||||
|
||||
updatesChannel := make(chan netlink.LinkUpdate)
|
||||
if err := netlink.LinkSubscribe(updatesChannel, nil); err != nil {
|
||||
return errors.Wrapf(err, "error monitoring link %q for UP/DOWN notifications", ifaceName)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for update := range updatesChannel {
|
||||
if update.Link.Attrs().Name == ifaceName && update.IfInfomsg.Flags&syscall.IFF_UP == 0 {
|
||||
log.Errorf("Interface %q which needs to be in UP state for Weave functioning is found to be in DOWN state", ifaceName)
|
||||
}
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user