From ecfccb8dc7e425cae587f11245838bc3c8f6dfa8 Mon Sep 17 00:00:00 2001 From: yl4811 Date: Fri, 31 Mar 2023 12:16:54 +0800 Subject: [PATCH 1/2] fix: invalid memory address --- pkg/controller/vpc_nat.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/controller/vpc_nat.go b/pkg/controller/vpc_nat.go index 1e03f37f45d..a5dc177003f 100644 --- a/pkg/controller/vpc_nat.go +++ b/pkg/controller/vpc_nat.go @@ -13,9 +13,14 @@ var ( func (c *Controller) resyncVpcNatConfig() { cm, err := c.configMapsLister.ConfigMaps(c.config.PodNamespace).Get(util.VpcNatConfig) - if err != nil && !k8serrors.IsNotFound(err) { + if err != nil { klog.Errorf("failed to get ovn-vpc-nat-config, %v", err) return } - vpcNatImage = cm.Data["image"] + image, exist := cm.Data["image"] + if !exist { + klog.Errorf("failed to get 'image' at ovn-vpc-nat-config") + return + } + vpcNatImage = image } From 63e280a424333ac5f94a91791a42ae291da73453 Mon Sep 17 00:00:00 2001 From: yl4811 Date: Fri, 31 Mar 2023 12:24:13 +0800 Subject: [PATCH 2/2] fix: invalid memory address --- pkg/controller/vpc_nat.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/controller/vpc_nat.go b/pkg/controller/vpc_nat.go index a5dc177003f..b9fbaa19687 100644 --- a/pkg/controller/vpc_nat.go +++ b/pkg/controller/vpc_nat.go @@ -14,6 +14,9 @@ var ( func (c *Controller) resyncVpcNatConfig() { cm, err := c.configMapsLister.ConfigMaps(c.config.PodNamespace).Get(util.VpcNatConfig) if err != nil { + if k8serrors.IsNotFound(err) { + return + } klog.Errorf("failed to get ovn-vpc-nat-config, %v", err) return }