@@ -296,8 +296,8 @@ func (r *OpenStackFloatingIPPoolReconciler) reconcileIPAddresses(ctx context.Con
296296 return err
297297 }
298298 }
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 )
301301 pool .Status .AvailableIPs = diff (unclaimedIPs , pool .Status .FailedIPs )
302302 return nil
303303}
@@ -313,7 +313,7 @@ func (r *OpenStackFloatingIPPoolReconciler) getIP(ctx context.Context, scope sco
313313 }
314314
315315 // 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
317317 if len (pool .Status .AvailableIPs ) == 0 {
318318 taggedIPs , err := networkingService .GetFloatingIPsByTag (pool .GetFloatingIPTag ())
319319 if err != nil {
@@ -332,6 +332,7 @@ func (r *OpenStackFloatingIPPoolReconciler) getIP(ctx context.Context, scope sco
332332 if len (pool .Status .AvailableIPs ) > 0 {
333333 ip = pool .Status .AvailableIPs [0 ]
334334 pool .Status .AvailableIPs = pool .Status .AvailableIPs [1 :]
335+ pool .Status .ClaimedIPs = append (pool .Status .ClaimedIPs , ip )
335336 }
336337
337338 if ip != "" {
@@ -342,15 +343,13 @@ func (r *OpenStackFloatingIPPoolReconciler) getIP(ctx context.Context, scope sco
342343 if fp != nil {
343344 return fp .FloatingIP , nil
344345 }
346+ pool .Status .FailedIPs = append (pool .Status .FailedIPs , ip )
345347 }
346348
347349 fp , err := networkingService .CreateFloatingIPForPool (pool )
348350 if err != nil {
349351 scope .Logger ().Error (err , "Failed to create floating IP" , "pool" , pool .Name )
350352 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- }
354353 return "" , err
355354 }
356355 defer func () {
0 commit comments