Skip to content

Force delete lb when deletion_protection is disabled #2172

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

Merged
merged 4 commits into from
Aug 17, 2021

Conversation

oliviassss
Copy link
Collaborator

@oliviassss oliviassss commented Aug 11, 2021

Issue

#1900

Description

This PR is to handle the deletion_protection.enabled for both ALB and NLB.

  • If deletion_protection.enabled=true is in the annotation and the customer deletes the load balancer, the controller will return error right away and refuse to reconcile further
  • Once the attribute gets edited to deletion_protection.enabled=false, the deployer will call ModifyLoadBalancerAttributes() to disable the deletion_protection, so it can continue to delete the resource.

Tests:

  • Created NLB, with deletion_protection.enabled=true, verified the service controller will return error and stop reconciling.
  • Then edited the attributes using kubectl edit svc/<my-svc> -n <my-namespace>, to set deletion_protection.enabled=false, verified the deployer will disable the deletion_protection and the resource got deleted.
  • Created ALB, with deletion_protection.enabled=true, verified the group controller will return error and stop reconciling.
  • Then edited the attributes using kubectl edit ingress/<my-ingress> -n <my-namespace>, to set deletion_protection.enabled=false, verified the deployer will disable the deletion_protection and the resource got deleted.

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 11, 2021
@k8s-ci-robot
Copy link
Contributor

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

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 11, 2021
@tanvp112
Copy link

@oliviassss, how do you set deletion_protection.enable=true for a nlb? alb.ingress.kubernetes.io/load-balancer-attributes is an annotation for ingress (does not support NLB) and not service. Can you shade a light here?

@kishorj
Copy link
Collaborator

kishorj commented Aug 13, 2021

@oliviassss, how do you set deletion_protection.enable=true for a nlb? alb.ingress.kubernetes.io/load-balancer-attributes is an annotation for ingress (does not support NLB) and not service. Can you shade a light here?

The deletion protection will be supported for NLB in the upcoming v2.3.0 release (PR #2051).

@oliviassss
Copy link
Collaborator Author

@tanvp112 You can add this annotation in the yaml file to enable deletion_protection for NLB: service.beta.kubernetes.io/aws-load-balancer-attributes: deletion_protection.enabled=true. Check this link

@kishorj
Copy link
Collaborator

kishorj commented Aug 13, 2021

/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 Aug 13, 2021
Copy link
Collaborator

@kishorj kishorj left a comment

Choose a reason for hiding this comment

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

With the proposed change, I see that if delete protection is not specified via annotation, but set on the NLB out-of-band, controller still force deletes the underlying NLB. This is contrary to the current design where controller doesn't nodify attributes not explicitly specified. This is a corner case, I agree, but lets see if it would make more sense to block the service deletion.

@oliviassss oliviassss force-pushed the deletion_protection branch from 99ee740 to 7b9fe71 Compare August 13, 2021 21:59
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 13, 2021
@oliviassss oliviassss changed the title NLB - force delete lb when deletion_protection is disabled Force delete lb when deletion_protection is disabled Aug 13, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #2172 (dae2125) into main (f861a8e) will decrease coverage by 0.10%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2172      +/-   ##
==========================================
- Coverage   52.34%   52.24%   -0.11%     
==========================================
  Files         132      132              
  Lines        7189     7203      +14     
==========================================
  Hits         3763     3763              
- Misses       3137     3151      +14     
  Partials      289      289              
Impacted Files Coverage Δ
pkg/deploy/elbv2/load_balancer_synthesizer.go 41.37% <0.00%> (-7.94%) ⬇️
pkg/service/model_builder.go 93.75% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f861a8e...dae2125. Read the comment docs.

@kishorj kishorj added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Aug 16, 2021
@oliviassss oliviassss force-pushed the deletion_protection branch from f6f33da to 3c6d288 Compare August 16, 2021 23:53
@oliviassss
Copy link
Collaborator Author

With the proposed change, I see that if delete protection is not specified via annotation, but set on the NLB out-of-band, controller still force deletes the underlying NLB. This is contrary to the current design where controller doesn't nodify attributes not explicitly specified. This is a corner case, I agree, but lets see if it would make more sense to block the service deletion.

According to our internal discussion, we will keep the method as it is now, and record this corner case situation in our documentation properly.

@kishorj
Copy link
Collaborator

kishorj commented Aug 17, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kishorj, oliviassss

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 17, 2021
@k8s-ci-robot k8s-ci-robot merged commit b382a94 into kubernetes-sigs:main Aug 17, 2021
@oliviassss oliviassss deleted the deletion_protection branch August 25, 2021 21:58
Timothy-Dougherty pushed a commit to adammw/aws-load-balancer-controller that referenced this pull request Nov 9, 2023
…#2172)

* force delete lb when deletion_protection is disabled

* check deletion_protection for ALB

* check deletion_protection in model builder step

* add unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants