Skip to content

Commit

Permalink
fix: wrong usage about DeepEqual (#3396)
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>
  • Loading branch information
bobz965 committed Nov 10, 2023
1 parent 6d6eef4 commit a3c7fb4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
9 changes: 6 additions & 3 deletions pkg/controller/external_gw.go
Expand Up @@ -78,7 +78,7 @@ func (c *Controller) removeExternalGateway() error {
sel, _ := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{MatchLabels: map[string]string{util.ExGatewayLabel: "true"}})
nodes, err := c.nodesLister.List(sel)
if err != nil {
klog.Errorf("failed to list nodes, %v", err)
klog.Errorf("failed to list external gw nodes, %v", err)
return err
}
for _, cachedNode := range nodes {
Expand Down Expand Up @@ -223,10 +223,13 @@ func (c *Controller) getGatewayChassis(config map[string]string) ([]string, erro
gwNodes = append(gwNodes, node.Name)
}
if config["type"] != "distributed" {
gwNodes = strings.Split(config["external-gw-nodes"], ",")
nodeNames := strings.Split(config["external-gw-nodes"], ",")
for _, name := range nodeNames {
name = strings.TrimSpace(name)
gwNodes = append(gwNodes, name)
}
}
for _, gw := range gwNodes {
gw = strings.TrimSpace(gw)
cachedNode, err := c.nodesLister.Get(gw)
if err != nil {
klog.Errorf("failed to get gw node %s, %v", gw, err)
Expand Down
5 changes: 2 additions & 3 deletions pkg/controller/ovn_eip.go
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -56,8 +55,8 @@ func (c *Controller) enqueueUpdateOvnEip(oldObj, newObj interface{}) {
c.resetOvnEipQueue.Add(key)
return
}
if !reflect.DeepEqual(oldEip.Spec.V4Ip, newEip.Spec.V4Ip) ||
!reflect.DeepEqual(oldEip.Spec.V6Ip, newEip.Spec.V6Ip) {
if oldEip.Spec.V4Ip != newEip.Spec.V4Ip ||
oldEip.Spec.V6Ip != newEip.Spec.V6Ip {
klog.Infof("enqueue update ovn eip %s", key)
c.updateOvnEipQueue.Add(key)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/controller/ovn_fip.go
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"reflect"
"strconv"

k8serrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -55,8 +54,8 @@ func (c *Controller) enqueueUpdateOvnFip(oldObj, newObj interface{}) {
klog.Infof("enqueue reset old ovn eip %s", oldFip.Spec.OvnEip)
c.resetOvnEipQueue.Add(oldFip.Spec.OvnEip)
}
if !reflect.DeepEqual(oldFip.Spec.IPName, newFip.Spec.IPName) ||
!reflect.DeepEqual(oldFip.Spec.IPType, newFip.Spec.IPType) {
if oldFip.Spec.IPName != newFip.Spec.IPName ||
oldFip.Spec.IPType != newFip.Spec.IPType {
klog.Infof("enqueue update fip %s", key)
c.updateOvnFipQueue.Add(key)
return
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/vpc.go
Expand Up @@ -51,10 +51,10 @@ func (c *Controller) enqueueUpdateVpc(oldObj, newObj interface{}) {
!reflect.DeepEqual(oldVpc.Spec.StaticRoutes, newVpc.Spec.StaticRoutes) ||
!reflect.DeepEqual(oldVpc.Spec.PolicyRoutes, newVpc.Spec.PolicyRoutes) ||
!reflect.DeepEqual(oldVpc.Spec.VpcPeerings, newVpc.Spec.VpcPeerings) ||
!reflect.DeepEqual(oldVpc.Spec.EnableExternal, newVpc.Spec.EnableExternal) ||
!reflect.DeepEqual(oldVpc.Spec.EnableBfd, newVpc.Spec.EnableBfd) ||
!reflect.DeepEqual(oldVpc.Annotations, newVpc.Annotations) ||
!reflect.DeepEqual(oldVpc.Spec.ExtraExternalSubnets, newVpc.Spec.ExtraExternalSubnets) ||
oldVpc.Spec.EnableExternal != newVpc.Spec.EnableExternal ||
oldVpc.Spec.EnableBfd != newVpc.Spec.EnableBfd ||
oldVpc.Labels[util.VpcExternalLabel] != newVpc.Labels[util.VpcExternalLabel] {
// TODO:// label VpcExternalLabel replace with spec enable external
var (
Expand Down

0 comments on commit a3c7fb4

Please sign in to comment.