@@ -524,27 +524,27 @@ func (c *Controller) handleUpdateNode(key string) error {
524
524
return nil
525
525
}
526
526
527
- func (c * Controller ) CheckGatewayReady () {
528
- if err := c .checkGatewayReady (); err != nil {
529
- klog .Errorf ("failed to check gateway ready %v" , err )
527
+ func (c * Controller ) checkSubnetGateway () {
528
+ if err := c .checkSubnetGatewayNode (); err != nil {
529
+ klog .Errorf ("failed to check subnet gateway node: %v" , err )
530
530
}
531
531
}
532
532
533
- func (c * Controller ) checkGatewayReady () error {
534
- klog .V (3 ).Infoln ("start to check gateway status " )
533
+ func (c * Controller ) checkSubnetGatewayNode () error {
534
+ klog .V (3 ).Infoln ("start to check subnet gateway node " )
535
535
subnetList , err := c .subnetsLister .List (labels .Everything ())
536
536
if err != nil {
537
- klog .Errorf ("failed to list subnets %v" , err )
537
+ klog .Errorf ("failed to list subnets: %v" , err )
538
538
return err
539
539
}
540
540
nodes , err := c .nodesLister .List (labels .Everything ())
541
541
if err != nil {
542
- klog .Errorf ("failed to list nodes, %v" , err )
542
+ klog .Errorf ("failed to list nodes: %v" , err )
543
543
return err
544
544
}
545
545
546
546
for _ , subnet := range subnetList {
547
- if (subnet .Spec .Vlan != "" && ! subnet .Spec .LogicalGateway ) ||
547
+ if (subnet .Spec .Vlan != "" && ( subnet . Spec . U2OInterconnection || ! subnet .Spec .LogicalGateway ) ) ||
548
548
subnet .Spec .GatewayNode == "" ||
549
549
subnet .Spec .GatewayType != kubeovnv1 .GWCentralizedType ||
550
550
! subnet .Spec .EnableEcmp {
@@ -582,24 +582,26 @@ func (c *Controller) checkGatewayReady() error {
582
582
pinger .Timeout = time .Duration (count ) * time .Second
583
583
pinger .Interval = 1 * time .Second
584
584
585
- success := false
586
-
585
+ var pingSucceeded bool
587
586
pinger .OnRecv = func (_ * goping.Packet ) {
588
- success = true
587
+ pingSucceeded = true
589
588
pinger .Stop ()
590
589
}
591
590
if err = pinger .Run (); err != nil {
592
591
klog .Errorf ("failed to run pinger for destination %s: %v" , ip , err )
593
592
return err
594
593
}
595
594
596
- if ! nodeReady (node ) {
597
- success = false
598
- }
599
-
600
- if ! success {
595
+ nodeIsReady := nodeReady (node )
596
+ if ! pingSucceeded || ! nodeIsReady {
601
597
if exist {
602
- klog .Warningf ("failed to ping ovn0 %s or node %s is not ready, delete ecmp policy route for node" , ip , node .Name )
598
+ if ! pingSucceeded {
599
+ klog .Warningf ("failed to ping ovn0 ip %s on node %s" , ip , node .Name )
600
+ }
601
+ if ! nodeIsReady {
602
+ klog .Warningf ("node %s is not ready" , node .Name )
603
+ }
604
+ klog .Warningf ("delete ecmp policy route for node %s ip %s" , node .Name , ip )
603
605
nextHops .Remove (ip )
604
606
delete (nameIPMap , node .Name )
605
607
klog .Infof ("update policy route for centralized subnet %s, nextHops %s" , subnet .Name , nextHops )
@@ -609,7 +611,7 @@ func (c *Controller) checkGatewayReady() error {
609
611
}
610
612
}
611
613
} else {
612
- klog .V (3 ).Infof ("succeed to ping gw %s " , ip )
614
+ klog .V (3 ).Infof ("succeeded to ping ovn0 ip %s on node %s " , ip , node . Name )
613
615
if ! exist {
614
616
nextHops .Add (ip )
615
617
if nameIPMap == nil {
@@ -624,7 +626,7 @@ func (c *Controller) checkGatewayReady() error {
624
626
}
625
627
}
626
628
} else if exist {
627
- klog .Infof ("subnet %s gatewayNode does not contains node %v , delete policy route for node ip %s" , subnet .Name , node .Name , ip )
629
+ klog .Infof ("subnet %s gateway nodes does not contain node %s , delete policy route for node ip %s" , subnet .Name , node .Name , ip )
628
630
nextHops .Remove (ip )
629
631
delete (nameIPMap , node .Name )
630
632
klog .Infof ("update policy route for centralized subnet %s, nextHops %s" , subnet .Name , nextHops )
0 commit comments