@@ -207,15 +207,57 @@ func (zic *ZoneInterconnectHandler) AddLocalZoneNode(node *corev1.Node) error {
207207// // See createRemoteZoneNodeResources() below for more details.
208208func (zic * ZoneInterconnectHandler ) AddRemoteZoneNode (node * corev1.Node ) error {
209209 start := time .Now ()
210- klog .Infof ("Creating interconnect resources for remote zone node %s for the network %s" , node .Name , zic .GetNetworkName ())
211210
212211 nodeID := util .GetNodeID (node )
213212 if nodeID == - 1 {
214213 // Don't consider this node as cluster-manager has not allocated node id yet.
215214 return fmt .Errorf ("failed to get node id for node - %s" , node .Name )
216215 }
217216
218- if err := zic .createRemoteZoneNodeResources (node , nodeID ); err != nil {
217+ nodeSubnets , err := util .ParseNodeHostSubnetAnnotation (node , zic .GetNetworkName ())
218+ if err != nil {
219+ err = fmt .Errorf ("failed to parse node %s subnets annotation %w" , node .Name , err )
220+ if util .IsAnnotationNotSetError (err ) {
221+ // remote node may not have the annotation yet, suppress it
222+ return types .NewSuppressedError (err )
223+ }
224+ return err
225+ }
226+
227+ nodeTransitSwitchPortIPs , err := util .ParseNodeTransitSwitchPortAddrs (node )
228+ if err != nil || len (nodeTransitSwitchPortIPs ) == 0 {
229+ err = fmt .Errorf ("failed to get the node transit switch port IP addresses : %w" , err )
230+ if util .IsAnnotationNotSetError (err ) {
231+ return types .NewSuppressedError (err )
232+ }
233+ return err
234+ }
235+
236+ var nodeGRPIPs []* net.IPNet
237+ // only primary networks have cluster router connected to join switch+GR
238+ // used for adding routes to GR
239+ if ! zic .IsSecondary () || (util .IsNetworkSegmentationSupportEnabled () && zic .IsPrimaryNetwork ()) {
240+ nodeGRPIPs , err = util .ParseNodeGatewayRouterJoinAddrs (node , zic .GetNetworkName ())
241+ if err != nil {
242+ if util .IsAnnotationNotSetError (err ) {
243+ // FIXME(tssurya): This is present for backwards compatibility
244+ // Remove me a few months from now
245+ var err1 error
246+ nodeGRPIPs , err1 = util .ParseNodeGatewayRouterLRPAddrs (node )
247+ if err1 != nil {
248+ err1 = fmt .Errorf ("failed to parse node %s Gateway router LRP Addrs annotation %w" , node .Name , err1 )
249+ if util .IsAnnotationNotSetError (err1 ) {
250+ return types .NewSuppressedError (err1 )
251+ }
252+ return err1
253+ }
254+ }
255+ }
256+ }
257+
258+ klog .Infof ("Creating interconnect resources for remote zone node %s for the network %s" , node .Name , zic .GetNetworkName ())
259+
260+ if err := zic .createRemoteZoneNodeResources (node , nodeID , nodeTransitSwitchPortIPs , nodeSubnets , nodeGRPIPs ); err != nil {
219261 return fmt .Errorf ("creating interconnect resources for remote zone node %s for the network %s failed : err - %w" , node .Name , zic .GetNetworkName (), err )
220262 }
221263 klog .Infof ("Creating Interconnect resources for node %q on network %q took: %s" , node .Name , zic .GetNetworkName (), time .Since (start ))
@@ -403,16 +445,7 @@ func (zic *ZoneInterconnectHandler) createLocalZoneNodeResources(node *corev1.No
403445// if the node name is ovn-worker and the network name is blue, the logical port name would be - blue.tstor.ovn-worker
404446// - binds the remote port to the node remote chassis in SBDB
405447// - adds static routes for the remote node via the remote port ip in the ovn_cluster_router
406- func (zic * ZoneInterconnectHandler ) createRemoteZoneNodeResources (node * corev1.Node , nodeID int ) error {
407- nodeTransitSwitchPortIPs , err := util .ParseNodeTransitSwitchPortAddrs (node )
408- if err != nil || len (nodeTransitSwitchPortIPs ) == 0 {
409- err = fmt .Errorf ("failed to get the node transit switch port IP addresses : %w" , err )
410- if util .IsAnnotationNotSetError (err ) {
411- return types .NewSuppressedError (err )
412- }
413- return err
414- }
415-
448+ func (zic * ZoneInterconnectHandler ) createRemoteZoneNodeResources (node * corev1.Node , nodeID int , nodeTransitSwitchPortIPs , nodeSubnets , nodeGRPIPs []* net.IPNet ) error {
416449 transitRouterPortMac := util .IPAddrToHWAddr (nodeTransitSwitchPortIPs [0 ].IP )
417450 var transitRouterPortNetworks []string
418451 for _ , ip := range nodeTransitSwitchPortIPs {
@@ -438,7 +471,7 @@ func (zic *ZoneInterconnectHandler) createRemoteZoneNodeResources(node *corev1.N
438471 return err
439472 }
440473
441- if err := zic .addRemoteNodeStaticRoutes (node , nodeTransitSwitchPortIPs ); err != nil {
474+ if err := zic .addRemoteNodeStaticRoutes (node , nodeTransitSwitchPortIPs , nodeSubnets , nodeGRPIPs ); err != nil {
442475 return err
443476 }
444477
@@ -534,7 +567,7 @@ func (zic *ZoneInterconnectHandler) cleanupNodeTransitSwitchPort(nodeName string
534567// Then the below static routes are added
535568// ip4.dst == 10.244.0.0/24 , nexthop = 100.88.0.2
536569// ip4.dst == 100.64.0.2/16 , nexthop = 100.88.0.2 (only for default primary network)
537- func (zic * ZoneInterconnectHandler ) addRemoteNodeStaticRoutes (node * corev1.Node , nodeTransitSwitchPortIPs []* net.IPNet ) error {
570+ func (zic * ZoneInterconnectHandler ) addRemoteNodeStaticRoutes (node * corev1.Node , nodeTransitSwitchPortIPs , nodeSubnets , nodeGRPIPs []* net.IPNet ) error {
538571 addRoute := func (prefix , nexthop string ) error {
539572 logicalRouterStaticRoute := nbdb.LogicalRouterStaticRoute {
540573 ExternalIDs : map [string ]string {
@@ -554,16 +587,6 @@ func (zic *ZoneInterconnectHandler) addRemoteNodeStaticRoutes(node *corev1.Node,
554587 return nil
555588 }
556589
557- nodeSubnets , err := util .ParseNodeHostSubnetAnnotation (node , zic .GetNetworkName ())
558- if err != nil {
559- err = fmt .Errorf ("failed to parse node %s subnets annotation %w" , node .Name , err )
560- if util .IsAnnotationNotSetError (err ) {
561- // remote node may not have the annotation yet, suppress it
562- return types .NewSuppressedError (err )
563- }
564- return err
565- }
566-
567590 nodeSubnetStaticRoutes := zic .getStaticRoutes (nodeSubnets , nodeTransitSwitchPortIPs , false )
568591 for _ , staticRoute := range nodeSubnetStaticRoutes {
569592 // Possible optimization: Add all the routes in one transaction
@@ -580,23 +603,6 @@ func (zic *ZoneInterconnectHandler) addRemoteNodeStaticRoutes(node *corev1.Node,
580603 return nil
581604 }
582605
583- nodeGRPIPs , err := util .ParseNodeGatewayRouterJoinAddrs (node , zic .GetNetworkName ())
584- if err != nil {
585- if util .IsAnnotationNotSetError (err ) {
586- // FIXME(tssurya): This is present for backwards compatibility
587- // Remove me a few months from now
588- var err1 error
589- nodeGRPIPs , err1 = util .ParseNodeGatewayRouterLRPAddrs (node )
590- if err1 != nil {
591- err1 = fmt .Errorf ("failed to parse node %s Gateway router LRP Addrs annotation %w" , node .Name , err1 )
592- if util .IsAnnotationNotSetError (err1 ) {
593- return types .NewSuppressedError (err1 )
594- }
595- return err1
596- }
597- }
598- }
599-
600606 nodeGRPIPStaticRoutes := zic .getStaticRoutes (nodeGRPIPs , nodeTransitSwitchPortIPs , true )
601607 for _ , staticRoute := range nodeGRPIPStaticRoutes {
602608 // Possible optimization: Add all the routes in one transaction
0 commit comments