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
refact/lb/sg: isolate sg deletion fragments to be reused
Isolating security group deletion fragments from EnsureLoadBalancerDeleted
to buildSecurityGroupsToDelete and deleteSecurityGroupsWithBackoff, so
the envaluation criteria and backof deletion can be reused in future
implementations, i.e. NLB with Security Groups.
klog.V(2).Infof("Ignoring DependencyViolation while deleting load-balancer security group (%s), assuming because LB is in process of deleting", securityGroupID)
2911
+
ignore=true
2912
+
}
2913
+
}
2914
+
if!ignore {
2915
+
returnfmt.Errorf("error while deleting load balancer security group (%s): %q", securityGroupID, err)
2916
+
}
2917
+
}
2918
+
2919
+
iflen(securityGroupIDs) ==0 {
2920
+
klog.V(2).Info("Deleted all security groups for load balancer: ", svcName)
2921
+
break
2922
+
}
2923
+
2924
+
iftime.Now().After(timeoutAt) {
2925
+
ids:= []string{}
2926
+
forid:=rangesecurityGroupIDs {
2927
+
ids=append(ids, id)
2928
+
}
2929
+
2930
+
returnfmt.Errorf("timed out deleting ELB: %s. Could not delete security groups %v after %d retries", svcName, strings.Join(ids, ","), retry)
2931
+
}
2932
+
2933
+
klog.V(2).Infof("Waiting for load-balancer %q to delete so we can delete security groups: %v", svcName, securityGroupIDs)
//We don't want to delete a security group that was defined in the Cloud Configuration.
2988
+
continue
2989
+
}
2990
+
ifsgID=="" {
2991
+
klog.Warningf("Ignoring empty security group in %s", service.Name)
2992
+
continue
2993
+
}
2994
+
2995
+
if!c.tagging.hasClusterTag(sg.Tags) {
2996
+
klog.Warningf("Ignoring security group with no cluster tag in %s", service.Name)
2997
+
continue
2998
+
} else {
2999
+
taggedLBSecurityGroups[sgID] =struct{}{}
3000
+
}
3001
+
3002
+
// 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`.
3003
+
if_, ok:=annotatedSgSet[sgID]; ok {
3004
+
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.
2965
-
continue
2966
-
}
2967
-
ifsgID=="" {
2968
-
klog.Warningf("Ignoring empty security group in %s", service.Name)
2969
-
continue
2970
-
}
2971
3085
2972
-
if!c.tagging.hasClusterTag(sg.Tags) {
2973
-
klog.Warningf("Ignoring security group with no cluster tag in %s", service.Name)
2974
-
continue
2975
-
} else {
2976
-
taggedLBSecurityGroups[sgID] =struct{}{}
2977
-
}
2978
-
2979
-
// 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`.
2980
-
if_, ok:=annotatedSgSet[sgID]; ok {
2981
-
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)
2982
-
continue
2983
-
}
2984
-
2985
-
securityGroupIDs[sgID] =struct{}{}
2986
-
}
2987
-
}
3086
+
// Delete the security group(s) for the load balancer
3087
+
// Note that this is annoying: the load balancer disappears from the API immediately, but it is still
3088
+
// 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)
3037
-
ignore=true
3038
-
}
3039
-
}
3040
-
if!ignore {
3041
-
returnfmt.Errorf("error while deleting load balancer security group (%s): %q", securityGroupID, err)
3042
-
}
3043
-
}
3044
-
}
3045
-
3046
-
iflen(securityGroupIDs) ==0 {
3047
-
klog.V(2).Info("Deleted all security groups for load balancer: ", service.Name)
3048
-
break
3049
-
}
3050
-
3051
-
iftime.Now().After(timeoutAt) {
3052
-
ids:= []string{}
3053
-
forid:=rangesecurityGroupIDs {
3054
-
ids=append(ids, id)
3055
-
}
3056
-
3057
-
returnfmt.Errorf("timed out deleting ELB: %s. Could not delete security groups %v", service.Name, strings.Join(ids, ","))
3058
-
}
3059
-
3060
-
klog.V(2).Info("Waiting for load-balancer to delete so we can delete security groups: ", service.Name)
0 commit comments