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

[octavia-lb] Add the logic to reattach the VIP to the load balancer if the IP has changed #2451

Closed
wants to merge 7 commits into from

Conversation

yang-wang11
Copy link

What this PR does / why we need it:

Which issue this PR fixes(if applicable):
fixes #2443

Special notes for reviewers:

Release note:

Enable OCCM to reassign the new Floating IP from service.spec when spec.loadBalancerIP is changed.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 24, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @yang-wang11!

It looks like this is your first PR to kubernetes/cloud-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/cloud-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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 24, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @yang-wang11. Thanks for your PR.

I'm waiting for a kubernetes 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 24, 2023
@yang-wang11
Copy link
Author

/test all

@k8s-ci-robot
Copy link
Contributor

@yang-wang11: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test all

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/test-infra repository.

@dulek
Copy link
Contributor

dulek commented Oct 24, 2023

/ok-to-test

@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 Oct 24, 2023
Copy link
Contributor

@dulek dulek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this enables users of the cluster to set spec.loadBalancerIP="", wait for a new FIP to get attached and repeat the process until all FIPs are exhausted. We shouldn't allow that. At minimum old FIP has to be deleted if it was created by the CPO.

@dulek
Copy link
Contributor

dulek commented Oct 24, 2023

Seems like this also breaks shared LBs:

E1024 12:12:45.460335      11 controller.go:298] error processing service octavia-lb-test/test-shared-2 (retrying with exponential backoff): failed to ensure load balancer: floating IP  is not available
I1024 12:12:45.460700      11 event.go:376] "Event occurred" object="octavia-lb-test/test-shared-2" fieldPath="" kind="Service" apiVersion="v1" type="Warning" reason="SyncLoadBalancerFailed" message="Error syncing load balancer: failed to ensure load balancer: floating IP  is not available"

Not that I like the feature, but we cannot just break it.

@yang-wang11
Copy link
Author

I think this enables users of the cluster to set spec.loadBalancerIP="", wait for a new FIP to get attached and repeat the process until all FIPs are exhausted. We shouldn't allow that. At minimum old FIP has to be deleted if it was created by the CPO.

@dulek Great observation, I will take some time to refactor this function to lessen the if-else.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 26, 2023
@yang-wang11
Copy link
Author

/retest

@yang-wang11
Copy link
Author

/assign @yang-wang11

@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 assign zetaab for approval. 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

@yang-wang11
Copy link
Author

/test all

@yang-wang11
Copy link
Author

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 3, 2023
@yang-wang11
Copy link
Author

@kayrus I'm not trying to rush you, but kindly look forward to your code review.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 7, 2023
Copy link
Contributor

@kayrus kayrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang-wang11 apologies that you had to wait. See my comments. As for the new ensureFloatingIP logic, give me a bit more time.

@@ -74,6 +74,7 @@ const (
ServiceAnnotationLoadBalancerFloatingSubnetTags = "loadbalancer.openstack.org/floating-subnet-tags"
ServiceAnnotationLoadBalancerClass = "loadbalancer.openstack.org/class"
ServiceAnnotationLoadBalancerKeepFloatingIP = "loadbalancer.openstack.org/keep-floatingip"
ServiceAnnotationLoadBalancerFloatingIP = "loadbalancer.openstack.org/floating-ip"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in order to comply with the previous naming, I'd suggest to use loadbalancer.openstack.org/floatingip
in future for dual stack we can use loadbalancer.openstack.org/floatingip-v6

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you mean loadbalancer.openstack.org/floatingip-v4 as the proposal. That's good for me.

@@ -431,6 +432,19 @@ func getSecurityGroupName(service *corev1.Service) string {
return securityGroupName
}

func getLoadBalancerIP(service *corev1.Service) string {
if annotations := service.Annotations; annotations != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can skip this check. if val, ok := annotations[ServiceAnnotationLoadBalancerFloatingIP]; ok && val != "" { is enough.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is used to avoid panic if there is no annotation. adopt your suggestion, it can cover my concern.
https://go.dev/play/p/RDerITo3dqp?v=goprev

@kayrus
Copy link
Contributor

kayrus commented Nov 16, 2023

@yang-wang11 Unfortunately I have doubts about the proposed ensureFloatingIP logic. I'm afraid the reconciliation port of the code is too fragile, and it requires a wider refactoring.

An example:

if floatIP == nil && !isLBOwner {
return "", fmt.Errorf("cannot attach a floating IP to a load balancer for a shared Service %s/%s, only owner Service can do that",
service.Namespace, service.Name)
}

why would we fail in this case? What if the loadbalancer has a service.beta.kubernetes.io/openstack-internal-load-balancer flag? There is no indication that this loadbalancer is going to be updated, therefore there is no reason to return an error.

There are also a bunch of minor concerns, which combination in result raises other questions.

Basically this is the reason why the #2377 PR is still in draft.

IMO the first step that we need to perform is to extend the mock API with Octavia support and add test cases which include a collection of different annotation combinations for services.

@yang-wang11 how critical is the issue for you? Does it occur only on svc update only?

@yang-wang11
Copy link
Author

@yang-wang11 Unfortunately I have doubts about the proposed ensureFloatingIP logic. I'm afraid the reconciliation port of the code is too fragile, and it requires a wider refactoring.

An example:

if floatIP == nil && !isLBOwner {
return "", fmt.Errorf("cannot attach a floating IP to a load balancer for a shared Service %s/%s, only owner Service can do that",
service.Namespace, service.Name)
}

why would we fail in this case? What if the loadbalancer has a service.beta.kubernetes.io/openstack-internal-load-balancer flag? There is no indication that this loadbalancer is going to be updated, therefore there is no reason to return an error.

There are also a bunch of minor concerns, which combination in result raises other questions.

Basically this is the reason why the #2377 PR is still in draft.

IMO the first step that we need to perform is to extend the mock API with Octavia support and add test cases which include a collection of different annotation combinations for services.

@yang-wang11 how critical is the issue for you? Does it occur only on svc update only?

@kayrus
I'm unsure if this change belongs to a refactor or not, the thing I did is combine similar logic. It aims to eliminate the if-else logic.
As we discussed in the Slack channel, the issue that occurred from the cluster was the update case, but not sure if there are others. we hope we can fix this issue at the earliest convenience.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 1, 2023
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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/test-infra repository.

@kayrus
Copy link
Contributor

kayrus commented Dec 11, 2023

@yang-wang11 can you resolve the conflicts?


This annotation is utilized to specify the floating IP for the load balancer.

If set, both newly created and pre-existing load balancers will utilize it. Furthermore, its precedence is higher than that of `Spec.LoadBalanccerIP`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If set, both newly created and pre-existing load balancers will utilize it. Furthermore, its precedence is higher than that of `Spec.LoadBalanccerIP`.
If set, both newly created and pre-existing load balancers will utilize it. Furthermore, its precedence is higher than that of `Spec.LoadBalancerIP`.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 10, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 9, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[occm] loadbalancer doesn't honor the spec.loadBalancerIP on service update
6 participants