Skip to content

WIP: 🐛 Fix SG deletion logic on Default VPC #5610

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/cloud/services/securitygroup/securitygroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func (s *Service) ReconcileSecurityGroups() error {
// skip rule reconciliation, as we expect the in-cluster cloud integration to manage them
continue
}
if sg.Name == "default" {
// skip rule reconciliation, as default SG group is already handled by revokeIngressAndEgressRulesFromVPCDefaultSecurityGroup
continue
}
current := sg.IngressRules

specRules, err := s.getSecurityGroupIngressRules(role)
Expand Down Expand Up @@ -516,8 +520,8 @@ func (s *Service) revokeSecurityGroupIngressRules(id string, rules infrav1.Ingre
rule := rules[i]
input.IpPermissions = append(input.IpPermissions, *ingressRuleToSDKType(s.scope, &rule))
}

if _, err := s.EC2Client.RevokeSecurityGroupIngress(context.TODO(), input); err != nil && !awserrors.IsPermissionNotFoundError(errors.Cause(err)) {
_, err := s.EC2Client.RevokeSecurityGroupIngress(context.TODO(), input)
if err != nil && !awserrors.IsPermissionNotFoundError(errors.Cause(err)) {
record.Warnf(s.scope.InfraCluster(), "FailedRevokeSecurityGroupIngressRules", "Failed to revoke security group ingress rules %v for SecurityGroup %q: %v", rules, id, err)
return errors.Wrapf(err, "failed to revoke security group %q ingress rules: %v", id, rules)
}
Expand Down