Skip to content

Commit

Permalink
fix: log
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <[email protected]>
  • Loading branch information
bobz965 committed Aug 22, 2024
1 parent d984cb0 commit d4cb176
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@ func (c *Controller) initDefaultLogicalSwitch() error {
defaultSubnet.Spec.U2OInterconnection = c.config.DefaultU2OInterconnection
}

_, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Create(context.Background(), &defaultSubnet, metav1.CreateOptions{})
return err
if _, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Create(context.Background(), &defaultSubnet, metav1.CreateOptions{}); err != nil {
klog.Errorf("failed to create default subnet %q: %v", c.config.DefaultLogicalSwitch, err)
return err
}
return nil
}

// InitNodeSwitch init node switch to connect host and pod
Expand Down Expand Up @@ -195,9 +198,8 @@ func (c *Controller) initNodeSwitch() error {
},
}

_, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Create(context.Background(), &nodeSubnet, metav1.CreateOptions{})
if err != nil {
klog.Errorf("failed to create subnet %s: %v", c.config.NodeSwitch, err)
if _, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Create(context.Background(), &nodeSubnet, metav1.CreateOptions{}); err != nil {
klog.Errorf("failed to create node subnet %q: %v", c.config.NodeSwitch, err)
return err
}
return nil
Expand Down Expand Up @@ -282,8 +284,7 @@ func (c *Controller) initLoadBalancer() error {
klog.Error(err)
return err
}
_, err = c.config.KubeOvnClient.KubeovnV1().Vpcs().Patch(context.Background(), vpc.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status")
if err != nil {
if _, err = c.config.KubeOvnClient.KubeovnV1().Vpcs().Patch(context.Background(), vpc.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status"); err != nil {
klog.Error(err)
return err
}
Expand Down Expand Up @@ -692,7 +693,7 @@ func (c *Controller) syncVpcNatGatewayCR() error {
// 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 %s, %v", util.VpcNatGatewayConfig, err)
klog.Errorf("failed to get config map %s, %v", util.VpcNatGatewayConfig, err)
return err
}
if k8serrors.IsNotFound(err) || cm.Data["enable-vpc-nat-gw"] == "false" {
Expand All @@ -702,15 +703,15 @@ func (c *Controller) syncVpcNatGatewayCR() error {
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)
klog.Errorf("should set config map for vpc-nat-gateway %s, %v", util.VpcNatConfig, err)
return err
}
klog.Errorf("failed to get %s, %v", util.VpcNatConfig, err)
klog.Errorf("failed to get config map %s, %v", util.VpcNatConfig, err)
return err
}

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

0 comments on commit d4cb176

Please sign in to comment.