Skip to content

Commit ed3ceb2

Browse files
anders-elastisysEmilienM
authored andcommitted
Update comments
1 parent 61b5b97 commit ed3ceb2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

controllers/openstackcluster_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ func (r *OpenStackClusterReconciler) deleteBastion(ctx context.Context, scope *s
251251
var statusFloatingIP *string
252252
var specFloatingIP *string
253253
if openStackCluster.Status.Bastion != nil && openStackCluster.Status.Bastion.FloatingIP != "" {
254-
// Floating IP set in status
255254
statusFloatingIP = &openStackCluster.Status.Bastion.FloatingIP
256255
}
257256
if openStackCluster.Spec.Bastion.FloatingIP != nil {
258-
// Floating IP from the spec
259257
specFloatingIP = openStackCluster.Spec.Bastion.FloatingIP
260258
}
261259

260+
// We only remove the bastion's floating IP if it exists and if it's not the same value defined both in the spec and in status.
261+
// This decision was made so if a user specifies a pre-created floating IP that is intended to only be used for the bastion, the floating IP won't get removed once the bastion is destroyed.
262262
if statusFloatingIP != nil && (specFloatingIP == nil || *statusFloatingIP != *specFloatingIP) {
263263
if err = networkingService.DeleteFloatingIP(openStackCluster, openStackCluster.Status.Bastion.FloatingIP); err != nil {
264264
handleUpdateOSCError(openStackCluster, fmt.Errorf("failed to delete floating IP: %w", err), false)
@@ -285,7 +285,8 @@ func (r *OpenStackClusterReconciler) deleteBastion(ctx context.Context, scope *s
285285

286286
for _, address := range addresses {
287287
if address.Type == corev1.NodeExternalIP {
288-
// If a floating IP is set for the bastion spec, skip deleting it
288+
// If a floating IP retrieved is the same as what is set in the bastion spec, skip deleting it.
289+
// This decision was made so if a user specifies a pre-created floating IP that is intended to only be used for the bastion, the floating IP won't get removed once the bastion is destroyed.
289290
if specFloatingIP != nil && address.Address == *specFloatingIP {
290291
continue
291292
}

0 commit comments

Comments
 (0)