Skip to content

Commit 38f18d2

Browse files
authored
Merge pull request #892 from e0ne/ignore-not-found
[sbr]: Ignore LinkNotFoundError during cmdDel
2 parents e513017 + 7e91841 commit 38f18d2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

plugins/meta/sbr/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,13 @@ func tidyRules(iface string) error {
360360

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

0 commit comments

Comments
 (0)