@@ -540,27 +540,27 @@ func (c *Controller) handleUpdateNode(key string) error {
540
540
return nil
541
541
}
542
542
543
- func (c * Controller ) CheckGatewayReady () {
544
- if err := c .checkGatewayReady (); err != nil {
545
- klog .Errorf ("failed to check gateway ready %v" , err )
543
+ func (c * Controller ) checkSubnetGateway () {
544
+ if err := c .checkSubnetGatewayNode (); err != nil {
545
+ klog .Errorf ("failed to check subnet gateway node: %v" , err )
546
546
}
547
547
}
548
548
549
- func (c * Controller ) checkGatewayReady () error {
550
- klog .V (3 ).Infoln ("start to check gateway status " )
549
+ func (c * Controller ) checkSubnetGatewayNode () error {
550
+ klog .V (3 ).Infoln ("start to check subnet gateway node " )
551
551
subnetList , err := c .subnetsLister .List (labels .Everything ())
552
552
if err != nil {
553
- klog .Errorf ("failed to list subnets %v" , err )
553
+ klog .Errorf ("failed to list subnets: %v" , err )
554
554
return err
555
555
}
556
556
nodes , err := c .nodesLister .List (labels .Everything ())
557
557
if err != nil {
558
- klog .Errorf ("failed to list nodes, %v" , err )
558
+ klog .Errorf ("failed to list nodes: %v" , err )
559
559
return err
560
560
}
561
561
562
562
for _ , subnet := range subnetList {
563
- if (subnet .Spec .Vlan != "" && ! subnet .Spec .LogicalGateway ) ||
563
+ if (subnet .Spec .Vlan != "" && ( subnet . Spec . U2OInterconnection || ! subnet .Spec .LogicalGateway ) ) ||
564
564
subnet .Spec .GatewayNode == "" ||
565
565
subnet .Spec .GatewayType != kubeovnv1 .GWCentralizedType ||
566
566
! subnet .Spec .EnableEcmp {
@@ -598,24 +598,26 @@ func (c *Controller) checkGatewayReady() error {
598
598
pinger .Timeout = time .Duration (count ) * time .Second
599
599
pinger .Interval = 1 * time .Second
600
600
601
- success := false
602
-
601
+ var pingSucceeded bool
603
602
pinger .OnRecv = func (_ * goping.Packet ) {
604
- success = true
603
+ pingSucceeded = true
605
604
pinger .Stop ()
606
605
}
607
606
if err = pinger .Run (); err != nil {
608
607
klog .Errorf ("failed to run pinger for destination %s: %v" , ip , err )
609
608
return err
610
609
}
611
610
612
- if ! nodeReady (node ) {
613
- success = false
614
- }
615
-
616
- if ! success {
611
+ nodeIsReady := nodeReady (node )
612
+ if ! pingSucceeded || ! nodeIsReady {
617
613
if exist {
618
- klog .Warningf ("failed to ping ovn0 %s or node %s is not ready, delete ecmp policy route for node" , ip , node .Name )
614
+ if ! pingSucceeded {
615
+ klog .Warningf ("failed to ping ovn0 ip %s on node %s" , ip , node .Name )
616
+ }
617
+ if ! nodeIsReady {
618
+ klog .Warningf ("node %s is not ready" , node .Name )
619
+ }
620
+ klog .Warningf ("delete ecmp policy route for node %s ip %s" , node .Name , ip )
619
621
nextHops .Remove (ip )
620
622
delete (nameIPMap , node .Name )
621
623
klog .Infof ("update policy route for centralized subnet %s, nextHops %s" , subnet .Name , nextHops )
@@ -625,7 +627,7 @@ func (c *Controller) checkGatewayReady() error {
625
627
}
626
628
}
627
629
} else {
628
- klog .V (3 ).Infof ("succeed to ping gw %s " , ip )
630
+ klog .V (3 ).Infof ("succeeded to ping ovn0 ip %s on node %s " , ip , node . Name )
629
631
if ! exist {
630
632
nextHops .Add (ip )
631
633
if nameIPMap == nil {
@@ -640,7 +642,7 @@ func (c *Controller) checkGatewayReady() error {
640
642
}
641
643
}
642
644
} else if exist {
643
- klog .Infof ("subnet %s gatewayNode does not contains node %v , delete policy route for node ip %s" , subnet .Name , node .Name , ip )
645
+ klog .Infof ("subnet %s gateway nodes does not contain node %s , delete policy route for node ip %s" , subnet .Name , node .Name , ip )
644
646
nextHops .Remove (ip )
645
647
delete (nameIPMap , node .Name )
646
648
klog .Infof ("update policy route for centralized subnet %s, nextHops %s" , subnet .Name , nextHops )
0 commit comments