[sbr]: Ignore LinkNotFoundError during cmdDel

Signed-off-by: Ivan Kolodyazhny <e0ne@e0ne.info>
This commit is contained in:
Ivan Kolodyazhny
2023-05-02 14:06:41 +03:00
parent 10b5639361
commit 7e918412d5

View File

@ -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)
}