From 7e918412d550bcddcb087cb567844c090de16702 Mon Sep 17 00:00:00 2001 From: Ivan Kolodyazhny Date: Tue, 2 May 2023 14:06:41 +0300 Subject: [PATCH] [sbr]: Ignore LinkNotFoundError during cmdDel Signed-off-by: Ivan Kolodyazhny --- plugins/meta/sbr/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/meta/sbr/main.go b/plugins/meta/sbr/main.go index 7a2892d2d..1f575f9ca 100644 --- a/plugins/meta/sbr/main.go +++ b/plugins/meta/sbr/main.go @@ -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) }