@@ -249,7 +249,18 @@ func (r *OpenStackClusterReconciler) deleteBastion(ctx context.Context, scope *s
249
249
return err
250
250
}
251
251
252
+ var statusFloatingIP * string
253
+ var specFloatingIP * string
252
254
if openStackCluster .Status .Bastion != nil && openStackCluster .Status .Bastion .FloatingIP != "" {
255
+ // Floating IP set in status
256
+ statusFloatingIP = & openStackCluster .Status .Bastion .FloatingIP
257
+ }
258
+ if openStackCluster .Spec .Bastion .FloatingIP != nil {
259
+ // Floating IP from the spec
260
+ specFloatingIP = openStackCluster .Spec .Bastion .FloatingIP
261
+ }
262
+
263
+ if statusFloatingIP != nil && (specFloatingIP == nil || * statusFloatingIP != * specFloatingIP ) {
253
264
if err = networkingService .DeleteFloatingIP (openStackCluster , openStackCluster .Status .Bastion .FloatingIP ); err != nil {
254
265
handleUpdateOSCError (openStackCluster , fmt .Errorf ("failed to delete floating IP: %w" , err ), false )
255
266
return fmt .Errorf ("failed to delete floating IP: %w" , err )
@@ -275,6 +286,10 @@ func (r *OpenStackClusterReconciler) deleteBastion(ctx context.Context, scope *s
275
286
276
287
for _ , address := range addresses {
277
288
if address .Type == corev1 .NodeExternalIP {
289
+ // If a floating IP is set for the bastion spec, skip deleting it
290
+ if specFloatingIP != nil && address .Address == * specFloatingIP {
291
+ continue
292
+ }
278
293
// Floating IP may not have properly saved in bastion status (thus not deleted above), delete any remaining floating IP
279
294
if err = networkingService .DeleteFloatingIP (openStackCluster , address .Address ); err != nil {
280
295
handleUpdateOSCError (openStackCluster , fmt .Errorf ("failed to delete floating IP: %w" , err ), false )
0 commit comments