You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
klog.V(2).Infof("Ignoring DependencyViolation while deleting load-balancer security group (%s), assuming because LB is in process of deleting", securityGroupID)
2877
+
ignore=true
2878
+
}
2879
+
}
2880
+
if!ignore {
2881
+
returntrue, fmt.Errorf("error while deleting load balancer security group (%s): %q", securityGroupID, err)
2882
+
}
2883
+
}
2884
+
2885
+
iflen(securityGroupIDs) ==0 {
2886
+
klog.V(2).Info("Deleted all security groups for load balancer: ", svcName)
2887
+
returntrue, nil
2888
+
}
2889
+
2890
+
klog.V(2).Infof("Waiting for load-balancer %q to delete so we can delete security groups: %v", svcName, securityGroupIDs)
2891
+
returnfalse, nil
2892
+
})
2893
+
iferr!=nil {
2894
+
ids:= []string{}
2895
+
forid:=rangesecurityGroupIDs {
2896
+
ids=append(ids, id)
2897
+
}
2898
+
returnfmt.Errorf("could not delete security groups %v for Load Balancer %q: %w", strings.Join(ids, ","), svcName, err)
2899
+
}
2900
+
returnnil
2901
+
}
2902
+
2903
+
// buildSecurityGroupsToDelete evaluates all deletion criteria and creates a list of valid security group IDs to be deleted.
2904
+
// It returns two maps:
2905
+
// - `securityGroupIDs`: A map of security group IDs that are eligible for deletion.
2906
+
// - `taggedLBSecurityGroups`: A map of security group IDs that are tagged and associated with the load balancer.
2907
+
// The function filters security groups based on the following criteria:
2908
+
// - Excludes security groups defined in the Cloud Configuration.
2909
+
// - Excludes security groups with no cluster tags.
2910
+
// - Excludes security groups annotated with `service.beta.kubernetes.io/aws-load-balancer-security-groups` or
//We don't want to delete a security group that was defined in the Cloud Configuration.
2948
+
continue
2949
+
}
2950
+
ifsgID=="" {
2951
+
klog.Warningf("Ignoring empty security group in %s", service.Name)
2952
+
continue
2953
+
}
2954
+
2955
+
if!c.tagging.hasClusterTag(sg.Tags) {
2956
+
klog.Warningf("Ignoring security group with no cluster tag in %s", service.Name)
2957
+
continue
2958
+
} else {
2959
+
taggedLBSecurityGroups[sgID] =struct{}{}
2960
+
}
2961
+
2962
+
// This is an extra protection of deletion of non provisioned Security Group which is annotated with `service.beta.kubernetes.io/aws-load-balancer-security-groups`.
2963
+
if_, ok:=annotatedSgSet[sgID]; ok {
2964
+
klog.Warningf("Ignoring security group with annotation `service.beta.kubernetes.io/aws-load-balancer-security-groups` or service.beta.kubernetes.io/aws-load-balancer-extra-security-groups in %s", service.Name)
//We don't want to delete a security group that was defined in the Cloud Configuration.
2940
-
continue
2941
-
}
2942
-
ifsgID=="" {
2943
-
klog.Warningf("Ignoring empty security group in %s", service.Name)
2944
-
continue
2945
-
}
2946
-
2947
-
if!c.tagging.hasClusterTag(sg.Tags) {
2948
-
klog.Warningf("Ignoring security group with no cluster tag in %s", service.Name)
2949
-
continue
2950
-
} else {
2951
-
taggedLBSecurityGroups[sgID] =struct{}{}
2952
-
}
2953
-
2954
-
// This is an extra protection of deletion of non provisioned Security Group which is annotated with `service.beta.kubernetes.io/aws-load-balancer-security-groups`.
2955
-
if_, ok:=annotatedSgSet[sgID]; ok {
2956
-
klog.Warningf("Ignoring security group with annotation `service.beta.kubernetes.io/aws-load-balancer-security-groups` or service.beta.kubernetes.io/aws-load-balancer-extra-security-groups in %s", service.Name)
2957
-
continue
2958
-
}
2959
-
2960
-
securityGroupIDs[sgID] =struct{}{}
2961
-
}
3046
+
// Delete the security group(s) for the load balancer
3047
+
// Note that this is annoying: the load balancer disappears from the API immediately, but it is still
3048
+
// deleting in the background. We get a DependencyViolation until the load balancer has deleted itself
klog.V(2).Infof("Ignoring DependencyViolation while deleting load-balancer security group (%s), assuming because LB is in process of deleting", securityGroupID)
3013
-
ignore=true
3014
-
}
3015
-
}
3016
-
if!ignore {
3017
-
returnfmt.Errorf("error while deleting load balancer security group (%s): %q", securityGroupID, err)
3018
-
}
3019
-
}
3020
-
}
3021
-
3022
-
iflen(securityGroupIDs) ==0 {
3023
-
klog.V(2).Info("Deleted all security groups for load balancer: ", service.Name)
3024
-
break
3025
-
}
3026
-
3027
-
iftime.Now().After(timeoutAt) {
3028
-
ids:= []string{}
3029
-
forid:=rangesecurityGroupIDs {
3030
-
ids=append(ids, id)
3031
-
}
3032
-
3033
-
returnfmt.Errorf("timed out deleting ELB: %s. Could not delete security groups %v", service.Name, strings.Join(ids, ","))
3034
-
}
3035
-
3036
-
klog.V(2).Info("Waiting for load-balancer to delete so we can delete security groups: ", service.Name)
0 commit comments