@@ -478,11 +478,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
478478 }
479479 }
480480
481- routeNeedDel , routeNeedAdd , err := diffStaticRoute (staticExistedRoutes , staticTargetRoutes )
482- if err != nil {
483- klog .Errorf ("failed to diff vpc %s static route, %v" , vpc .Name , err )
484- return err
485- }
481+ routeNeedDel , routeNeedAdd := diffStaticRoute (staticExistedRoutes , staticTargetRoutes )
486482
487483 for _ , item := range routeNeedDel {
488484 klog .Infof ("vpc %s del static route: %+v" , vpc .Name , item )
@@ -608,7 +604,6 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
608604 if subnet .Status .IsNotReady () {
609605 c .addOrUpdateSubnetQueue .Add (subnet .Name )
610606 }
611- c .addOrUpdateSubnetQueue .Add (subnet .Name )
612607 if vpc .Name != util .DefaultVpc && vpc .Spec .EnableBfd && subnet .Spec .EnableEcmp {
613608 custVpcEnableExternalEcmp = true
614609 }
@@ -760,7 +755,7 @@ func (c *Controller) handleUpdateVpcExternal(vpc *kubeovnv1.Vpc, custVpcEnableEx
760755 }
761756 }
762757
763- if err := c .updateVpcExternalStatus (vpc .Name , vpc . Spec . EnableExternal ); err != nil {
758+ if err := c .updateVpcExternalStatus (vpc .Name ); err != nil {
764759 klog .Errorf ("failed to update vpc external subnets status, %v" , err )
765760 return err
766761 }
@@ -1015,11 +1010,12 @@ func diffPolicyRouteWithLogical(exists []*ovnnb.LogicalRouterPolicy, target []*k
10151010 key string
10161011 ok bool
10171012 )
1013+ klog .Infof ("diffPolicyRouteWithLogical exists: %v, target: %v" , exists , target )
10181014 existsMap = make (map [string ]* kubeovnv1.PolicyRoute , len (exists ))
10191015
10201016 for _ , item := range exists {
10211017 if item .ExternalIDs ["vpc-egress-gateway" ] != "" ||
1022- item .ExternalIDs ["isU2ORoutePolicy" ] ! = "true" {
1018+ item .ExternalIDs ["isU2ORoutePolicy" ] = = "true" {
10231019 continue
10241020 }
10251021 policy := & kubeovnv1.PolicyRoute {
@@ -1029,6 +1025,7 @@ func diffPolicyRouteWithLogical(exists []*ovnnb.LogicalRouterPolicy, target []*k
10291025 }
10301026 existsMap [getPolicyRouteItemKey (policy )] = policy
10311027 }
1028+ klog .Infof ("diffPolicyRouteWithLogical existsMap: %v" , existsMap )
10321029
10331030 for _ , item := range target {
10341031 key = getPolicyRouteItemKey (item )
@@ -1040,17 +1037,20 @@ func diffPolicyRouteWithLogical(exists []*ovnnb.LogicalRouterPolicy, target []*k
10401037 }
10411038 }
10421039
1040+ klog .Infof ("diffPolicyRouteWithLogical existsMap after delete: %v" , existsMap )
1041+
10431042 for _ , item := range existsMap {
10441043 dels = append (dels , item )
10451044 }
1045+ klog .Infof ("diffPolicyRouteWithLogical dels: %v, adds: %v" , dels , adds )
10461046 return dels , adds
10471047}
10481048
10491049func getPolicyRouteItemKey (item * kubeovnv1.PolicyRoute ) (key string ) {
10501050 return fmt .Sprintf ("%d:%s:%s:%s" , item .Priority , item .Match , item .Action , item .NextHopIP )
10511051}
10521052
1053- func diffStaticRoute (exist []* ovnnb.LogicalRouterStaticRoute , target []* kubeovnv1.StaticRoute ) (routeNeedDel , routeNeedAdd []* kubeovnv1.StaticRoute , err error ) {
1053+ func diffStaticRoute (exist []* ovnnb.LogicalRouterStaticRoute , target []* kubeovnv1.StaticRoute ) (routeNeedDel , routeNeedAdd []* kubeovnv1.StaticRoute ) {
10541054 existRouteMap := make (map [string ]* kubeovnv1.StaticRoute , len (exist ))
10551055 for _ , item := range exist {
10561056 policy := kubeovnv1 .PolicyDst
@@ -1081,7 +1081,7 @@ func diffStaticRoute(exist []*ovnnb.LogicalRouterStaticRoute, target []*kubeovnv
10811081 for _ , item := range existRouteMap {
10821082 routeNeedDel = append (routeNeedDel , item )
10831083 }
1084- return routeNeedDel , routeNeedAdd , err
1084+ return routeNeedDel , routeNeedAdd
10851085}
10861086
10871087func getStaticRouteItemKey (item * kubeovnv1.StaticRoute ) string {
@@ -1361,14 +1361,15 @@ func (c *Controller) handleDeleteVpcStaticRoute(key string) error {
13611361 needUpdate := false
13621362 newStaticRoutes := make ([]* kubeovnv1.StaticRoute , 0 , len (vpc .Spec .StaticRoutes ))
13631363 for _ , route := range vpc .Spec .StaticRoutes {
1364- if route .ECMPMode != util .StaticRouteBfdEcmp {
1365- newStaticRoutes = append (newStaticRoutes , route )
1364+ if route .ECMPMode == util .StaticRouteBfdEcmp {
13661365 needUpdate = true
1366+ continue
13671367 }
1368+ newStaticRoutes = append (newStaticRoutes , route )
13681369 }
1369- // keep non ecmp bfd routes
1370- vpc .Spec .StaticRoutes = newStaticRoutes
1370+ // keep routes except bfd ecmp routes
13711371 if needUpdate {
1372+ vpc .Spec .StaticRoutes = newStaticRoutes
13721373 if _ , err = c .config .KubeOvnClient .KubeovnV1 ().Vpcs ().Update (context .Background (), vpc , metav1.UpdateOptions {}); err != nil {
13731374 klog .Errorf ("failed to update vpc spec static route %s, %v" , vpc .Name , err )
13741375 return err
@@ -1438,7 +1439,7 @@ func (c *Controller) getRouteTablesByVpc(vpc *kubeovnv1.Vpc) map[string][]*kubeo
14381439 return rtbs
14391440}
14401441
1441- func (c * Controller ) updateVpcExternalStatus (key string , enableExternal bool ) error {
1442+ func (c * Controller ) updateVpcExternalStatus (key string ) error {
14421443 cachedVpc , err := c .vpcsLister .Get (key )
14431444 if err != nil {
14441445 klog .Errorf ("failed to get vpc %s, %v" , key , err )
@@ -1448,7 +1449,7 @@ func (c *Controller) updateVpcExternalStatus(key string, enableExternal bool) er
14481449 vpc .Status .EnableExternal = vpc .Spec .EnableExternal
14491450 vpc .Status .EnableBfd = vpc .Spec .EnableBfd
14501451
1451- if enableExternal {
1452+ if vpc . Spec . EnableExternal {
14521453 sort .Strings (vpc .Spec .ExtraExternalSubnets )
14531454 vpc .Status .ExtraExternalSubnets = vpc .Spec .ExtraExternalSubnets
14541455 } else {
0 commit comments