Skip to content

Commit

Permalink
[sbr]: Ignore LinkNotFoundError during cmdDel
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Kolodyazhny <e0ne@e0ne.info>
  • Loading branch information
e0ne committed May 2, 2023
1 parent 10b5639 commit 7e91841
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugins/meta/sbr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ func tidyRules(iface string) error {

link, err := netlink.LinkByName(iface)
if err != nil {
// If interface is not found by any reason it's safe to ignore an error. Also, we don't need to raise an error
// during cmdDel call according to CNI spec:
// https://github.com/containernetworking/cni/blob/main/SPEC.md#del-remove-container-from-network-or-un-apply-modifications
_, notFound := err.(netlink.LinkNotFoundError)
if notFound {
return nil
}
log.Printf("Failed to get link %s: %v", iface, err)
return fmt.Errorf("Failed to get link %s: %v", iface, err)
}
Expand Down

0 comments on commit 7e91841

Please sign in to comment.