-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not delete bastion floating ip if set in spec #2257
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,7 +244,18 @@ func (r *OpenStackClusterReconciler) deleteBastion(ctx context.Context, scope *s | |
return err | ||
} | ||
|
||
var statusFloatingIP *string | ||
var specFloatingIP *string | ||
if openStackCluster.Status.Bastion != nil && openStackCluster.Status.Bastion.FloatingIP != "" { | ||
// Floating IP set in status | ||
statusFloatingIP = &openStackCluster.Status.Bastion.FloatingIP | ||
} | ||
if openStackCluster.Spec.Bastion.FloatingIP != nil { | ||
// Floating IP from the spec | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove that comment, I think it's too obvious. |
||
specFloatingIP = openStackCluster.Spec.Bastion.FloatingIP | ||
} | ||
|
||
if statusFloatingIP != nil && (specFloatingIP == nil || *statusFloatingIP != *specFloatingIP) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here please add a comment on what opinionated decision we make.
Or something like that. |
||
if err = networkingService.DeleteFloatingIP(openStackCluster, openStackCluster.Status.Bastion.FloatingIP); err != nil { | ||
handleUpdateOSCError(openStackCluster, fmt.Errorf("failed to delete floating IP: %w", err), false) | ||
return fmt.Errorf("failed to delete floating IP: %w", err) | ||
|
@@ -270,6 +281,10 @@ func (r *OpenStackClusterReconciler) deleteBastion(ctx context.Context, scope *s | |
|
||
for _, address := range addresses { | ||
if address.Type == corev1.NodeExternalIP { | ||
// If a floating IP is set for the bastion spec, skip deleting it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, put more context in this comment. |
||
if specFloatingIP != nil && address.Address == *specFloatingIP { | ||
continue | ||
} | ||
// Floating IP may not have properly saved in bastion status (thus not deleted above), delete any remaining floating IP | ||
if err = networkingService.DeleteFloatingIP(openStackCluster, address.Address); err != nil { | ||
handleUpdateOSCError(openStackCluster, fmt.Errorf("failed to delete floating IP: %w", err), false) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove that comment, I think it's too obvious.