@@ -296,8 +296,8 @@ func (r *OpenStackFloatingIPPoolReconciler) reconcileIPAddresses(ctx context.Con
296
296
return err
297
297
}
298
298
}
299
- unclaimedPreAllocatedIPs := diff (pool .Spec . PreAllocatedFloatingIPs , pool .Status . ClaimedIPs )
300
- unclaimedIPs := union ( pool .Status .AvailableIPs , unclaimedPreAllocatedIPs )
299
+ allIPs := union (pool .Status . AvailableIPs , pool .Spec . PreAllocatedFloatingIPs )
300
+ unclaimedIPs := diff ( allIPs , pool .Status .ClaimedIPs )
301
301
pool .Status .AvailableIPs = diff (unclaimedIPs , pool .Status .FailedIPs )
302
302
return nil
303
303
}
@@ -313,7 +313,7 @@ func (r *OpenStackFloatingIPPoolReconciler) getIP(ctx context.Context, scope sco
313
313
}
314
314
315
315
// Get tagged floating IPs and add them to the available IPs if they are not present in either the available IPs or the claimed IPs
316
- // This is done to prevent leaking floating IPs if to prevent leaking floating IPs if the floating IP was created but the IPAddress object was not
316
+ // This is done to prevent leaking floating IPs if the floating IP was created but the IPAddress object was not
317
317
if len (pool .Status .AvailableIPs ) == 0 {
318
318
taggedIPs , err := networkingService .GetFloatingIPsByTag (pool .GetFloatingIPTag ())
319
319
if err != nil {
@@ -332,6 +332,7 @@ func (r *OpenStackFloatingIPPoolReconciler) getIP(ctx context.Context, scope sco
332
332
if len (pool .Status .AvailableIPs ) > 0 {
333
333
ip = pool .Status .AvailableIPs [0 ]
334
334
pool .Status .AvailableIPs = pool .Status .AvailableIPs [1 :]
335
+ pool .Status .ClaimedIPs = append (pool .Status .ClaimedIPs , ip )
335
336
}
336
337
337
338
if ip != "" {
@@ -342,15 +343,13 @@ func (r *OpenStackFloatingIPPoolReconciler) getIP(ctx context.Context, scope sco
342
343
if fp != nil {
343
344
return fp .FloatingIP , nil
344
345
}
346
+ pool .Status .FailedIPs = append (pool .Status .FailedIPs , ip )
345
347
}
346
348
347
349
fp , err := networkingService .CreateFloatingIPForPool (pool )
348
350
if err != nil {
349
351
scope .Logger ().Error (err , "Failed to create floating IP" , "pool" , pool .Name )
350
352
conditions .MarkFalse (pool , infrav1alpha1 .OpenstackFloatingIPPoolReadyCondition , infrav1 .OpenStackErrorReason , clusterv1 .ConditionSeverityError , "Failed to create floating IP: %v" , err )
351
- if ip != "" {
352
- pool .Status .FailedIPs = append (pool .Status .FailedIPs , ip )
353
- }
354
353
return "" , err
355
354
}
356
355
defer func () {
0 commit comments