EnsureBridge used to skip creation and initialization of the weave bridge and friends if such existed. This caused problems when EnsureBridge failed before completing all init steps and so, subsequent weaver could not work without "weave reset". This change makes EnsureBridge idempotent.
17 lines
288 B
Go
17 lines
288 B
Go
package net
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/vishvananda/netlink"
|
|
)
|
|
|
|
func LinkAddIfNotExist(link netlink.Link) error {
|
|
err := netlink.LinkAdd(link)
|
|
if err != nil && err == syscall.EEXIST {
|
|
return nil
|
|
}
|
|
return errors.Wrapf(err, "creating link %q", link)
|
|
}
|