@@ -230,7 +230,7 @@ func (eit *EgressIPTracker) UpdateHostSubnetEgress(hs *networkapi.HostSubnet) {
230
230
movedEgressIPs := make ([]string , 0 , node .requestedIPs .Len ())
231
231
for _ , ip := range node .requestedIPs .UnsortedList () {
232
232
eg := eit .egressIPs [ip ]
233
- if eg .assignedNodeIP == node .nodeIP {
233
+ if eg != nil && eg .assignedNodeIP == node .nodeIP {
234
234
movedEgressIPs = append (movedEgressIPs , ip )
235
235
eit .deleteNodeEgressIP (node , ip )
236
236
}
@@ -308,7 +308,9 @@ func (eit *EgressIPTracker) UpdateNetNamespaceEgress(netns *networkapi.NetNamesp
308
308
// Even IPs that weren't added/removed need to be considered "changed", to
309
309
// ensure we correctly process reorderings, duplicates added/removed, etc.
310
310
for _ , ip := range newRequestedIPs .Intersection (oldRequestedIPs ).UnsortedList () {
311
- eit .egressIPChanged (eit .egressIPs [ip ])
311
+ if eg := eit .egressIPs [ip ]; eg != nil {
312
+ eit .egressIPChanged (eg )
313
+ }
312
314
}
313
315
314
316
eit .syncEgressIPs ()
@@ -332,7 +334,7 @@ func (eit *EgressIPTracker) egressIPActive(eg *egressIPInfo) (bool, error) {
332
334
}
333
335
for _ , ip := range eg .namespaces [0 ].requestedIPs {
334
336
eg2 := eit .egressIPs [ip ]
335
- if eg2 != eg && len (eg2 .nodes ) == 1 && eg2 .nodes [0 ] == eg .nodes [0 ] {
337
+ if eg2 != nil && eg2 != eg && len (eg2 .nodes ) == 1 && eg2 .nodes [0 ] == eg .nodes [0 ] {
336
338
return false , fmt .Errorf ("Multiple EgressIPs (%s, %s) for VNID %d on node %s" , eg .ip , eg2 .ip , eg .namespaces [0 ].vnid , eg .nodes [0 ].nodeIP )
337
339
}
338
340
}
@@ -358,6 +360,12 @@ func (eit *EgressIPTracker) syncEgressIPs() {
358
360
eit .syncEgressNamespaceState (ns )
359
361
}
360
362
363
+ for eg := range changedEgressIPs {
364
+ if len (eg .namespaces ) == 0 && len (eg .nodes ) == 0 {
365
+ delete (eit .egressIPs , eg .ip )
366
+ }
367
+ }
368
+
361
369
if eit .updateEgressCIDRs {
362
370
eit .updateEgressCIDRs = false
363
371
if eit .nodesWithCIDRs > 0 {
@@ -539,7 +547,7 @@ func (eit *EgressIPTracker) ReallocateEgressIPs() map[string][]string {
539
547
540
548
// Allocate pending egress IPs that can only go to a single node
541
549
for egressIP , eip := range eit .egressIPs {
542
- if alreadyAllocated [egressIP ] {
550
+ if alreadyAllocated [egressIP ] || len ( eip . namespaces ) == 0 {
543
551
continue
544
552
}
545
553
nodeName , otherNodes := eit .findEgressIPAllocation (eip .parsed , allocation )
@@ -551,7 +559,7 @@ func (eit *EgressIPTracker) ReallocateEgressIPs() map[string][]string {
551
559
}
552
560
// Allocate any other pending egress IPs that we can
553
561
for egressIP , eip := range eit .egressIPs {
554
- if alreadyAllocated [egressIP ] {
562
+ if alreadyAllocated [egressIP ] || len ( eip . namespaces ) == 0 {
555
563
continue
556
564
}
557
565
nodeName , _ := eit .findEgressIPAllocation (eip .parsed , allocation )
0 commit comments