-
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?
Do not delete bastion floating ip if set in spec #2257
Conversation
Welcome @anders-elastisys! |
Hi @anders-elastisys. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
/ok-to-test
/lgtm
@EmilienM I think you're the expert in this code.
@anders-elastisys: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
if openStackCluster.Status.Bastion != nil && openStackCluster.Status.Bastion.FloatingIP != "" { | ||
// Floating IP set in status |
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.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Here please add a comment on what opinionated decision we make.
We only remove the bastion's floating IP if it exists and if it's the not same value defined both in the spec and in status. This decision was made so if a user specifies a pre-created floating IP that is intended to be used for the bastion, the floating IP won't get removed once the bastion is destroyed.
Or something like that.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
same here, put more context in this comment.
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.
Thanks for your contribution.
I've put some comments inline.
I don't want to be picky but I honestly think we should have e2e coverage for this PR, simply because the code around bastion has proven to break quite easily and I've spent hours fixing it.
Please have a look at how we test a flavor change for the bastion:
shared.Logf("Create the bastion with a new flavor") |
and see if we can do the same kind of testing:
- Create a FIP using Gophercloud
- Update the cluster spec to provide that FIP in Bastion
- Check that the bastion uses that FIP
- Delete the Bastion, make sure the FIP was not deleted
- Delete the FIP
Let me know if it's too much asked, I can help.
If you want to do the tests as a follow-up, we can also do that and in that case I'll approve this PR.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks for the comments, I will take try to add e2e tests when I get the time, if I am not successful in this I'll let you know. |
awesome; thanks. And if we don't manage it to do it in a timely manner, I can merge as is and do the tests afterwards. |
What this PR does / why we need it:
This PR makes it so that if an floatingIP is set in the
openstackcluster.spec.bastion.floatingIP
, and it is the same as set in thestatus
of theopenstackcluster
resource, it will not be deleted when deleting the cluster.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #2157
Special notes for your reviewer:
My issue got stale so I am creating this PR so that hopefully this feature does not get forgotten.
TODOs:
/hold