-
Notifications
You must be signed in to change notification settings - Fork 672
handle gracefully add/delete of vethwedu dummy interface #3459
base: master
Are you sure you want to change the base?
Conversation
net/bridge.go
Outdated
return errors.Wrap(err, "creating dummy interface") | ||
} | ||
defer func() { | ||
var dummyIf netlink.Link | ||
dummyIf, err = netlink.LinkByName(WeaveDummyIfName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just use dummy
here ?
net/bridge.go
Outdated
return errors.Wrap(err, "creating dummy interface") | ||
} | ||
defer func() { | ||
var dummy netlink.Link | ||
dummy, err = netlink.LinkByName(WeaveDummyIfName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just re-use the dummy
variable that was initialized earlier, instead of creating a new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don't even have to assign to it - the initialization earlier leaves dummy
in a state where you can just use it. Unless I'm missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I changed the logic to re-use dummy
. PTAL
aa6db6c
to
7f85a01
Compare
return errors.Wrap(err, "creating dummy interface") | ||
} | ||
defer func() { | ||
if err = netlink.LinkDel(dummy); err != nil { | ||
err = errors.Wrap(err, "deleting dummy interface") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think assigning to the local variable err
at this point has no effect.
If err
is made a named return value from initPrep
it would work, but suppose both LinkSetMTU
and LinkDel
fail, we'd only see one error.
Maybe use a different err
to record the LinkDel()
result and use Wrap()
to add the previous error (if any).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, Wrap()
can only wrap one error. Maybe just add the text of this one to the previous one, if it exists.
use
LinkAddIfNotExist
to add dummy interface, and delete dummy interface indefer
blockfixes #3414