@@ -459,6 +459,23 @@ 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+ // Add static routes created by addCustomVPCStaticRouteForSubnet
469+ for _ , subnet := range subnets {
470+ if subnet .Spec .Vpc == key {
471+ staticTargetRoutes = append (staticTargetRoutes , & kubeovnv1.StaticRoute {
472+ Policy : kubeovnv1 .PolicySrc ,
473+ CIDR : subnet .Spec .CIDRBlock ,
474+ NextHopIP : subnet .Spec .Gateway ,
475+ RouteTable : subnet .Spec .RouteTable ,
476+ })
477+ }
478+ }
462479 }
463480
464481 routeNeedDel , routeNeedAdd , err := diffStaticRoute (staticExistedRoutes , staticTargetRoutes )
@@ -508,21 +525,13 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
508525 // diff list
509526 policyRouteNeedDel , policyRouteNeedAdd = diffPolicyRouteWithExisted (policyRouteExisted , vpc .Spec .PolicyRoutes )
510527 } 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 )
528+ policyRouteLogical , err = c .OVNNbClient .ListLogicalRouterPolicies (vpc .Name , - 1 , nil , true )
529+ if err != nil {
530+ klog .Errorf ("failed to get vpc %s policy route list, %v" , vpc .Name , err )
531+ return err
525532 }
533+ // diff vpc policy route
534+ policyRouteNeedDel , policyRouteNeedAdd = diffPolicyRouteWithLogical (policyRouteLogical , vpc .Spec .PolicyRoutes )
526535 }
527536 // delete policies non-exist
528537 for _ , item := range policyRouteNeedDel {
@@ -594,6 +603,11 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
594603 custVpcEnableExternalEcmp := false
595604 for _ , subnet := range subnets {
596605 if subnet .Spec .Vpc == key {
606+ // Accelerate subnet update when vpc config is updated.
607+ // In case VPC not set namespaces, subnet will backoff and may take long time to back to ready.
608+ if subnet .Status .IsNotReady () {
609+ c .addOrUpdateSubnetQueue .Add (subnet .Name )
610+ }
597611 c .addOrUpdateSubnetQueue .Add (subnet .Name )
598612 if vpc .Name != util .DefaultVpc && vpc .Spec .EnableBfd && subnet .Spec .EnableEcmp {
599613 custVpcEnableExternalEcmp = true
@@ -1066,6 +1080,10 @@ func diffPolicyRouteWithLogical(exists []*ovnnb.LogicalRouterPolicy, target []*k
10661080 existsMap = make (map [string ]* kubeovnv1.PolicyRoute , len (exists ))
10671081
10681082 for _ , item := range exists {
1083+ if item .ExternalIDs ["vpc-egress-gateway" ] != "" ||
1084+ item .ExternalIDs ["isU2ORoutePolicy" ] != "true" {
1085+ continue
1086+ }
10691087 policy := & kubeovnv1.PolicyRoute {
10701088 Priority : item .Priority ,
10711089 Match : item .Match ,
0 commit comments