Merge pull request #892 from e0ne/ignore-not-found

[sbr]: Ignore LinkNotFoundError during cmdDel
This commit is contained in:
Casey Callendrello 2023-05-03 21:53:21 +02:00 committed by GitHub
commit 38f18d26ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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