Skip to content

Commit

Permalink
fix initialization check of vpc nat gateway configuration (#2978)
Browse files Browse the repository at this point in the history
* fix initialization check of vpc nat gateway configuration

* make error messages clearer
  • Loading branch information
qiutingjun authored Jun 25, 2023
1 parent e558702 commit 65fd8a4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"context"
"errors"
"fmt"
"strings"
"time"
Expand Down Expand Up @@ -697,14 +698,32 @@ func (c *Controller) initSyncCrdSubnets() error {

func (c *Controller) initSyncCrdVpcNatGw() error {
klog.Info("start to sync crd vpc nat gw")
// get vpc nat gateway enable state
cm, err := c.configMapsLister.ConfigMaps(c.config.PodNamespace).Get(util.VpcNatGatewayConfig)
if err != nil && !k8serrors.IsNotFound(err) {
klog.Errorf("failed to get ovn-vpc-nat-gw-config, %v", err)
klog.Errorf("failed to get %s, %v", util.VpcNatGatewayConfig, err)
return err
}
if k8serrors.IsNotFound(err) || cm.Data["enable-vpc-nat-gw"] == "false" || cm.Data["image"] == "" {
if k8serrors.IsNotFound(err) || cm.Data["enable-vpc-nat-gw"] == "false" {
return nil
}
// get vpc nat gateway image
cm, err = c.configMapsLister.ConfigMaps(c.config.PodNamespace).Get(util.VpcNatConfig)
if err != nil {
if k8serrors.IsNotFound(err) {
klog.Errorf("configMap of %s not set, %v", util.VpcNatConfig, err)
return err
}
klog.Errorf("failed to get %s, %v", util.VpcNatConfig, err)
return err
}

if cm.Data["image"] == "" {
err = errors.New("image of vpc-nat-gateway not set")
klog.Error(err)
return err
}

gws, err := c.vpcNatGatewayLister.List(labels.Everything())
if err != nil {
klog.Errorf("failed to list vpc nat gateway, %v", err)
Expand Down

0 comments on commit 65fd8a4

Please sign in to comment.