@@ -459,6 +459,22 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
459459 }
460460 }
461461 }
462+ } else {
463+ subnets , err := c .subnetsLister .List (labels .Everything ())
464+ if err != nil {
465+ klog .Error (err )
466+ return err
467+ }
468+ for _ , subnet := range subnets {
469+ if subnet .Spec .Vpc == key {
470+ staticTargetRoutes = append (staticTargetRoutes , & kubeovnv1.StaticRoute {
471+ Policy : kubeovnv1 .PolicySrc ,
472+ CIDR : subnet .Spec .CIDRBlock ,
473+ NextHopIP : subnet .Spec .Gateway ,
474+ RouteTable : subnet .Spec .RouteTable ,
475+ })
476+ }
477+ }
462478 }
463479
464480 routeNeedDel , routeNeedAdd , err := diffStaticRoute (staticExistedRoutes , staticTargetRoutes )
@@ -508,21 +524,13 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
508524 // diff list
509525 policyRouteNeedDel , policyRouteNeedAdd = diffPolicyRouteWithExisted (policyRouteExisted , vpc .Spec .PolicyRoutes )
510526 } else {
511- if vpc .Spec .PolicyRoutes == nil {
512- // do not clean default vpc policy routes
513- if err = c .OVNNbClient .ClearLogicalRouterPolicy (vpc .Name ); err != nil {
514- klog .Errorf ("clean all vpc %s policy route failed, %v" , vpc .Name , err )
515- return err
516- }
517- } else {
518- policyRouteLogical , err = c .OVNNbClient .ListLogicalRouterPolicies (vpc .Name , - 1 , nil , true )
519- if err != nil {
520- klog .Errorf ("failed to get vpc %s policy route list, %v" , vpc .Name , err )
521- return err
522- }
523- // diff vpc policy route
524- policyRouteNeedDel , policyRouteNeedAdd = diffPolicyRouteWithLogical (policyRouteLogical , vpc .Spec .PolicyRoutes )
527+ policyRouteLogical , err = c .OVNNbClient .ListLogicalRouterPolicies (vpc .Name , - 1 , nil , true )
528+ if err != nil {
529+ klog .Errorf ("failed to get vpc %s policy route list, %v" , vpc .Name , err )
530+ return err
525531 }
532+ // diff vpc policy route
533+ policyRouteNeedDel , policyRouteNeedAdd = diffPolicyRouteWithLogical (policyRouteLogical , vpc .Spec .PolicyRoutes )
526534 }
527535 // delete policies non-exist
528536 for _ , item := range policyRouteNeedDel {
@@ -594,6 +602,11 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
594602 custVpcEnableExternalEcmp := false
595603 for _ , subnet := range subnets {
596604 if subnet .Spec .Vpc == key {
605+ // Accelerate subnet update when vpc config is updated.
606+ // In case VPC not set namespaces, subnet will backoff and may take long time to back to ready.
607+ if subnet .Status .IsNotReady () {
608+ c .addOrUpdateSubnetQueue .Add (subnet .Name )
609+ }
597610 c .addOrUpdateSubnetQueue .Add (subnet .Name )
598611 if vpc .Name != util .DefaultVpc && vpc .Spec .EnableBfd && subnet .Spec .EnableEcmp {
599612 custVpcEnableExternalEcmp = true
@@ -1066,6 +1079,10 @@ func diffPolicyRouteWithLogical(exists []*ovnnb.LogicalRouterPolicy, target []*k
10661079 existsMap = make (map [string ]* kubeovnv1.PolicyRoute , len (exists ))
10671080
10681081 for _ , item := range exists {
1082+ if item .ExternalIDs ["vpc-egress-gateway" ] != "" ||
1083+ item .ExternalIDs ["isU2ORoutePolicy" ] != "true" {
1084+ continue
1085+ }
10691086 policy := & kubeovnv1.PolicyRoute {
10701087 Priority : item .Priority ,
10711088 Match : item .Match ,
0 commit comments