cloud-provider-aws icon indicating copy to clipboard operation
cloud-provider-aws copied to clipboard

Ensure removal of security group rules on deleting load balancers

Open JoelSpeed opened this issue 1 year ago • 11 comments

What type of PR is this? /kind bug

What this PR does / why we need it:

This PR updates the load balancer security group update logic for ELBs so that we can actually delete a security group when there is an untagged group present.

In the current flow, we can add rules to the security group if it is untagged, but we cannot remove them since the logic excludes untagged groups from the actualGroups list. When we are deleting the load balancer and deleting the security group, we need to make sure that we remove all rules that refer to the security group else the security group deletion will reach a dependency violation deadlock.

To ensure compatibility with BYO security groups, the code ensures that we only pass the isDeleting parameter as true when the existing logic determines that the load balancer should be removing the security group already. This should mean that we only do the full removal of all references when we are about to delete the security group, and if the security group is being left over, we won't remove any references - I don't think in the BYO security group case we have any way to track what we have added so I can't fix that bug here.

Which issue(s) this PR fixes:

Fixes #566

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

When removing a load balancer, the service controller will now remove all security group rules referencing the load balancer's security group, even when the security group containing the rule is unmanaged.

JoelSpeed avatar Nov 23 '23 17:11 JoelSpeed