diff --git a/pkg/networking/subnet_resolver.go b/pkg/networking/subnet_resolver.go index db90fa057..5186299d7 100644 --- a/pkg/networking/subnet_resolver.go +++ b/pkg/networking/subnet_resolver.go @@ -198,7 +198,10 @@ func (r *defaultSubnetsResolver) ResolveViaSelector(ctx context.Context, selecto }, }, } + + targetTagKeys := []string{} for key, values := range selector.Tags { + targetTagKeys = append(targetTagKeys, key) req.Filters = append(req.Filters, &ec2sdk.Filter{ Name: awssdk.String("tag:" + key), Values: awssdk.StringSlice(values), @@ -209,7 +212,8 @@ func (r *defaultSubnetsResolver) ResolveViaSelector(ctx context.Context, selecto if err != nil { return nil, err } - explanation = fmt.Sprintf("%d match VPC and tags", len(allSubnets)) + explanation = fmt.Sprintf("%d match VPC and tags: %s", len(allSubnets), targetTagKeys) + var subnets []*ec2sdk.Subnet taggedOtherCluster := 0 for _, subnet := range allSubnets { diff --git a/pkg/networking/subnet_resolver_test.go b/pkg/networking/subnet_resolver_test.go index 5de8d060a..8859e0123 100644 --- a/pkg/networking/subnet_resolver_test.go +++ b/pkg/networking/subnet_resolver_test.go @@ -203,7 +203,7 @@ func Test_defaultSubnetsResolver_ResolveViaDiscovery(t *testing.T) { }, }, { - name: "ALB with no matching subnets", + name: "ALB with no matching subnets (internal)", fields: fields{ vpcID: "vpc-1", clusterName: "kube-cluster", @@ -231,7 +231,38 @@ func Test_defaultSubnetsResolver_ResolveViaDiscovery(t *testing.T) { WithSubnetsResolveLBScheme(elbv2model.LoadBalancerSchemeInternal), }, }, - wantErr: errors.New("unable to resolve at least one subnet (0 match VPC and tags)"), + wantErr: errors.New("unable to resolve at least one subnet (0 match VPC and tags: [kubernetes.io/role/internal-elb])"), + }, + { + name: "ALB with no matching subnets (internet-facing)", + fields: fields{ + vpcID: "vpc-1", + clusterName: "kube-cluster", + describeSubnetsAsListCalls: []describeSubnetsAsListCall{ + { + input: &ec2sdk.DescribeSubnetsInput{ + Filters: []*ec2sdk.Filter{ + { + Name: awssdk.String("vpc-id"), + Values: awssdk.StringSlice([]string{"vpc-1"}), + }, + { + Name: awssdk.String("tag:kubernetes.io/role/elb"), + Values: awssdk.StringSlice([]string{"", "1"}), + }, + }, + }, + output: nil, + }, + }, + }, + args: args{ + opts: []SubnetsResolveOption{ + WithSubnetsResolveLBType(elbv2model.LoadBalancerTypeApplication), + WithSubnetsResolveLBScheme(elbv2model.LoadBalancerSchemeInternetFacing), + }, + }, + wantErr: errors.New("unable to resolve at least one subnet (0 match VPC and tags: [kubernetes.io/role/elb])"), }, { name: "NLB with one matching subnet",