From aab435df857d9bc294593e3bdf076a6fb588dd7d Mon Sep 17 00:00:00 2001 From: l1b0k Date: Wed, 29 May 2024 10:18:45 +0800 Subject: [PATCH] cni: ignore link if not present Signed-off-by: l1b0k --- plugin/driver/utils/utils_linux.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin/driver/utils/utils_linux.go b/plugin/driver/utils/utils_linux.go index e4d8bb39..97ea58f9 100644 --- a/plugin/driver/utils/utils_linux.go +++ b/plugin/driver/utils/utils_linux.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "net" + "os" terwayIP "github.com/AliyunContainerService/terway/pkg/ip" terwaySysctl "github.com/AliyunContainerService/terway/pkg/sysctl" @@ -354,7 +355,9 @@ func EnsureNetConfSet(ipv4, ipv6 bool) error { for _, cfg := range ipv4NetConfig { innerErr := terwaySysctl.EnsureConf(fmt.Sprintf(cfg[0], link.Attrs().Name), cfg[1]) if innerErr != nil { - err = fmt.Errorf("%v, %w", err, innerErr) + if !os.IsNotExist(innerErr) { + err = fmt.Errorf("%v, %w", err, innerErr) + } } } } @@ -362,7 +365,9 @@ func EnsureNetConfSet(ipv4, ipv6 bool) error { for _, cfg := range ipv6NetConfig { innerErr := terwaySysctl.EnsureConf(fmt.Sprintf(cfg[0], link.Attrs().Name), cfg[1]) if innerErr != nil { - err = fmt.Errorf("%v, %w", err, innerErr) + if !os.IsNotExist(innerErr) { + err = fmt.Errorf("%v, %w", err, innerErr) + } } } }