Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anders-elastisys
Copy link

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 the status of the openstackcluster 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.

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • if necessary:
    • includes documentation
    • adds unit tests

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 18, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 18, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @anders-elastisys!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-openstack 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-openstack has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 18, 2024
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit c1fe7b8
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/673af31a1ef44f000848fa8a
😎 Deploy Preview https://deploy-preview-2257--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@mdbooth mdbooth left a 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.

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 26, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 26, 2024
@k8s-ci-robot
Copy link
Contributor

@anders-elastisys: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-openstack-test c1fe7b8 link true /test pull-cluster-api-provider-openstack-test
pull-cluster-api-provider-openstack-e2e-test c1fe7b8 link true /test pull-cluster-api-provider-openstack-e2e-test

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
Copy link
Contributor

@EmilienM EmilienM Nov 26, 2024

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
Copy link
Contributor

@EmilienM EmilienM Nov 26, 2024

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) {
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

@EmilienM EmilienM left a 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.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from mdbooth. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@anders-elastisys
Copy link
Author

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.

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.

@EmilienM
Copy link
Contributor

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: Inbox
Development

Successfully merging this pull request may close these issues.

Keep Floating IP when deleting bastion host
4 participants