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