Skip to content

Commit

Permalink
Merge pull request #892 from e0ne/ignore-not-found
Browse files Browse the repository at this point in the history
[sbr]: Ignore LinkNotFoundError during cmdDel
  • Loading branch information
squeed committed May 3, 2023
2 parents e513017 + 7e91841 commit 38f18d2
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 38f18d2

Please sign in to comment.