@@ -1881,35 +1881,6 @@ func ValidateHealthCheck(s *elbtypes.HealthCheck) error {
18811881 return nil
18821882}
18831883
1884- // isOwnedSecurityGroup checks if the security group is owned by the controller
1885- // by checking if the security group has the cluster ownership tag
1886- // (kubernetes.io/cluster/<clusterID>=owned).
1887- //
1888- // Parameters:
1889- // - `ctx`: The context for the operation.
1890- // - `securityGroupID`: The ID of the security group to check.
1891- //
1892- // Returns:
1893- // - `bool`: True if the security group is owned by the controller, false otherwise.
1894- // - `error`: An error if the security group cannot be retrieved, is not found,
1895- // or if multiple security groups are found with the same ID (unexpected).
1896- func (c * Cloud ) isOwnedSecurityGroup (ctx context.Context , securityGroupID string ) (bool , error ) {
1897- groups , err := c .ec2 .DescribeSecurityGroups (ctx , & ec2.DescribeSecurityGroupsInput {
1898- GroupIds : []string {securityGroupID },
1899- })
1900- if err != nil {
1901- return false , fmt .Errorf ("error retrieving security group %q: %w" , securityGroupID , err )
1902- }
1903- if len (groups ) == 0 {
1904- return false , fmt .Errorf ("security group %q not found" , securityGroupID )
1905- }
1906- if len (groups ) != 1 {
1907- // This should not be possible - ids should be unique
1908- return false , fmt .Errorf ("[BUG] multiple security groups(%d) found with same id %q" , len (groups ), securityGroupID )
1909- }
1910- return c .tagging .hasClusterTagOwned (groups [0 ].Tags )
1911- }
1912-
19131884// buildSecurityGroupRuleReferences finds all security groups that have ingress rules
19141885// referencing the specified security group ID, and categorizes them based on cluster tagging.
19151886// This is used to identify dependencies before removing a security group.
0 commit comments