diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 643adb61906..e3bafdef480 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -1026,11 +1026,15 @@ func (c *Controller) startWorkers(ctx context.Context) { // maintain l3 ha about the vpc external lrp binding to the gw chassis c.OVNNbClient.MonitorBFD() } - + // TODO: we should merge these two vpc nat config into one config and resync them together go wait.Until(func() { c.resyncVpcNatGwConfig() }, time.Second, ctx.Done()) + go wait.Until(func() { + c.resyncVpcNatImage() + }, time.Second, ctx.Done()) + go wait.Until(func() { if err := c.markAndCleanLSP(); err != nil { klog.Errorf("gc lsp error: %v", err) diff --git a/pkg/controller/service_lb.go b/pkg/controller/service_lb.go index ef693905066..9b3a276118d 100644 --- a/pkg/controller/service_lb.go +++ b/pkg/controller/service_lb.go @@ -69,10 +69,6 @@ func (c *Controller) checkAttachNetwork(svc *corev1.Service) error { } func (c *Controller) genLbSvcDeployment(svc *corev1.Service) (dp *v1.Deployment) { - if err := c.resyncVpcNatImage(); err != nil { - klog.Errorf("failed to resync vpc nat config, err: %v", err) - return nil - } name := genLbSvcDpName(svc.Name) labels := map[string]string{ "app": name, diff --git a/pkg/controller/vpc_lb.go b/pkg/controller/vpc_lb.go index f7d4fc21ead..96469a40180 100644 --- a/pkg/controller/vpc_lb.go +++ b/pkg/controller/vpc_lb.go @@ -66,10 +66,6 @@ func (c *Controller) deleteVpcLb(vpc *kubeovnv1.Vpc) error { } func (c *Controller) genVpcLbDeployment(vpc *kubeovnv1.Vpc) (*v1.Deployment, error) { - if err := c.resyncVpcNatImage(); err != nil { - klog.Errorf("failed to resync vpc nat config, err: %v", err) - return nil, err - } if len(vpc.Status.Subnets) == 0 { return nil, nil } diff --git a/pkg/controller/vpc_nat.go b/pkg/controller/vpc_nat.go index a32693c0b6d..bad302866ef 100644 --- a/pkg/controller/vpc_nat.go +++ b/pkg/controller/vpc_nat.go @@ -10,19 +10,22 @@ import ( var vpcNatImage = "" -func (c *Controller) resyncVpcNatImage() error { +func (c *Controller) resyncVpcNatImage() { + if vpcNatEnabled != "true" { + return + } + cm, err := c.configMapsLister.ConfigMaps(c.config.PodNamespace).Get(util.VpcNatConfig) if err != nil { err = fmt.Errorf("failed to get ovn-vpc-nat-config, %v", err) klog.Error(err) - return err + return } image, exist := cm.Data["image"] if !exist { err = fmt.Errorf("%s should have image field", util.VpcNatConfig) klog.Error(err) - return err + return } vpcNatImage = image - return nil } diff --git a/pkg/controller/vpc_nat_gateway.go b/pkg/controller/vpc_nat_gateway.go index 4097e1d74ac..5449f4c8c63 100644 --- a/pkg/controller/vpc_nat_gateway.go +++ b/pkg/controller/vpc_nat_gateway.go @@ -87,10 +87,6 @@ func (c *Controller) resyncVpcNatGwConfig() { klog.Errorf("failed to get vpc nat gateway, %v", err) return } - if err = c.resyncVpcNatImage(); err != nil { - klog.Errorf("failed to resync vpc nat config, err: %v", err) - return - } vpcNatEnabled = "true" VpcNatCmVersion = cm.ResourceVersion for _, gw := range gws {