@@ -459,6 +459,20 @@ 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+ staticTargetRoutes = append (staticTargetRoutes , & kubeovnv1.StaticRoute {
470+ Policy : kubeovnv1 .PolicySrc ,
471+ CIDR : subnet .Spec .CIDRBlock ,
472+ NextHopIP : subnet .Spec .Gateway ,
473+ RouteTable : subnet .Spec .RouteTable ,
474+ })
475+ }
462476 }
463477
464478 routeNeedDel , routeNeedAdd , err := diffStaticRoute (staticExistedRoutes , staticTargetRoutes )
@@ -508,21 +522,13 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
508522 // diff list
509523 policyRouteNeedDel , policyRouteNeedAdd = diffPolicyRouteWithExisted (policyRouteExisted , vpc .Spec .PolicyRoutes )
510524 } 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 )
525+ policyRouteLogical , err = c .OVNNbClient .ListLogicalRouterPolicies (vpc .Name , - 1 , nil , true )
526+ if err != nil {
527+ klog .Errorf ("failed to get vpc %s policy route list, %v" , vpc .Name , err )
528+ return err
525529 }
530+ // diff vpc policy route
531+ policyRouteNeedDel , policyRouteNeedAdd = diffPolicyRouteWithLogical (policyRouteLogical , vpc .Spec .PolicyRoutes )
526532 }
527533 // delete policies non-exist
528534 for _ , item := range policyRouteNeedDel {
@@ -594,6 +600,11 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
594600 custVpcEnableExternalEcmp := false
595601 for _ , subnet := range subnets {
596602 if subnet .Spec .Vpc == key {
603+ // Accelerate subnet update when vpc config is updated.
604+ // In case VPC not set namespaces, subnet will backoff and may take long time to back to ready.
605+ if subnet .Status .IsNotReady () {
606+ c .addOrUpdateSubnetQueue .Add (subnet .Name )
607+ }
597608 c .addOrUpdateSubnetQueue .Add (subnet .Name )
598609 if vpc .Name != util .DefaultVpc && vpc .Spec .EnableBfd && subnet .Spec .EnableEcmp {
599610 custVpcEnableExternalEcmp = true
@@ -1066,6 +1077,10 @@ func diffPolicyRouteWithLogical(exists []*ovnnb.LogicalRouterPolicy, target []*k
10661077 existsMap = make (map [string ]* kubeovnv1.PolicyRoute , len (exists ))
10671078
10681079 for _ , item := range exists {
1080+ if item .ExternalIDs ["vpc-egress-gateway" ] != "" ||
1081+ item .ExternalIDs ["isU2ORoutePolicy" ] != "true" {
1082+ continue
1083+ }
10691084 policy := & kubeovnv1.PolicyRoute {
10701085 Priority : item .Priority ,
10711086 Match : item .Match ,
0 commit comments