@@ -498,22 +498,20 @@ func (eit *EgressIPTracker) findEgressIPAllocation(ip net.IP, allocation map[str
498
498
return bestNode , otherNodes
499
499
}
500
500
501
- // ReallocateEgressIPs returns a map from Node name to array-of-Egress-IP. Unchanged nodes are not included.
501
+ // ReallocateEgressIPs returns a map from Node name to array-of-Egress-IP for all auto-allocated egress IPs
502
502
func (eit * EgressIPTracker ) ReallocateEgressIPs () map [string ][]string {
503
503
eit .Lock ()
504
504
defer eit .Unlock ()
505
505
506
506
allocation := make (map [string ][]string )
507
- changed := make (map [string ]bool )
508
507
alreadyAllocated := make (map [string ]bool )
509
508
for _ , node := range eit .nodes {
510
509
if len (node .parsedCIDRs ) > 0 {
511
510
allocation [node .nodeName ] = make ([]string , 0 , node .requestedIPs .Len ())
512
511
}
513
512
}
514
513
// For each active egress IP, if it still fits within some egress CIDR on its node,
515
- // add it to that node's allocation. (Otherwise add the node to the "changed" map,
516
- // since we'll be removing this egress IP from it.)
514
+ // add it to that node's allocation.
517
515
for egressIP , eip := range eit .egressIPs {
518
516
if eip .assignedNodeIP == "" {
519
517
continue
@@ -528,8 +526,6 @@ func (eit *EgressIPTracker) ReallocateEgressIPs() map[string][]string {
528
526
}
529
527
if found {
530
528
allocation [node .nodeName ] = append (allocation [node .nodeName ], egressIP )
531
- } else {
532
- changed [node .nodeName ] = true
533
529
}
534
530
// (We set alreadyAllocated even if the egressIP will be removed from
535
531
// its current node; we can't assign it to a new node until the next
@@ -545,7 +541,6 @@ func (eit *EgressIPTracker) ReallocateEgressIPs() map[string][]string {
545
541
nodeName , otherNodes := eit .findEgressIPAllocation (eip .parsed , allocation )
546
542
if nodeName != "" && ! otherNodes {
547
543
allocation [nodeName ] = append (allocation [nodeName ], egressIP )
548
- changed [nodeName ] = true
549
544
alreadyAllocated [egressIP ] = true
550
545
}
551
546
}
@@ -557,15 +552,8 @@ func (eit *EgressIPTracker) ReallocateEgressIPs() map[string][]string {
557
552
nodeName , _ := eit .findEgressIPAllocation (eip .parsed , allocation )
558
553
if nodeName != "" {
559
554
allocation [nodeName ] = append (allocation [nodeName ], egressIP )
560
- changed [nodeName ] = true
561
555
}
562
556
}
563
557
564
- // Remove unchanged nodes from the return value
565
- for _ , node := range eit .nodes {
566
- if ! changed [node .nodeName ] {
567
- delete (allocation , node .nodeName )
568
- }
569
- }
570
558
return allocation
571
559
}
0 commit comments