Skip to content

Commit 074ff36

Browse files
Update comments
1 parent f712e66 commit 074ff36

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

controllers/openstackcluster_controller.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ func (r *OpenStackClusterReconciler) deleteBastion(ctx context.Context, scope *s
252252
var statusFloatingIP *string
253253
var specFloatingIP *string
254254
if openStackCluster.Status.Bastion != nil && openStackCluster.Status.Bastion.FloatingIP != "" {
255-
// Floating IP set in status
256255
statusFloatingIP = &openStackCluster.Status.Bastion.FloatingIP
257256
}
258257
if openStackCluster.Spec.Bastion.FloatingIP != nil {
259-
// Floating IP from the spec
260258
specFloatingIP = openStackCluster.Spec.Bastion.FloatingIP
261259
}
262260

261+
// 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.
262+
// 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.
263263
if statusFloatingIP != nil && (specFloatingIP == nil || *statusFloatingIP != *specFloatingIP) {
264264
if err = networkingService.DeleteFloatingIP(openStackCluster, openStackCluster.Status.Bastion.FloatingIP); err != nil {
265265
handleUpdateOSCError(openStackCluster, fmt.Errorf("failed to delete floating IP: %w", err), false)
@@ -286,7 +286,8 @@ func (r *OpenStackClusterReconciler) deleteBastion(ctx context.Context, scope *s
286286

287287
for _, address := range addresses {
288288
if address.Type == corev1.NodeExternalIP {
289-
// If a floating IP is set for the bastion spec, skip deleting it
289+
// If a floating IP retrieved is the same as what is set in the bastion spec, skip deleting it.
290+
// 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.
290291
if specFloatingIP != nil && address.Address == *specFloatingIP {
291292
continue
292293
}

0 commit comments

Comments
 (0)