From a9cd814e5525927cd259234013741412ff5bdc24 Mon Sep 17 00:00:00 2001 From: Ellis Tarn Date: Thu, 24 Jun 2021 13:14:54 -0700 Subject: [PATCH] Check if subnets are empty before passing to the instance provider --- pkg/cloudprovider/aws/subnets.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/cloudprovider/aws/subnets.go b/pkg/cloudprovider/aws/subnets.go index b29ad4ffe027..d600befbc6bd 100644 --- a/pkg/cloudprovider/aws/subnets.go +++ b/pkg/cloudprovider/aws/subnets.go @@ -57,6 +57,11 @@ func (s *SubnetProvider) Get(ctx context.Context, provisioner *v1alpha1.Provisio if len(constraints.Zones) != 0 { subnets = filterSubnets(subnets, withSubnetZone(predicates.WithinStrings(constraints.Zones))) } + // 4. Fail if no subnets found, since the constraints may be violated and + // node cannot connect to the API Server. + if len(subnets) == 0 { + return nil, fmt.Errorf("no subnets exist given constraints") + } return subnets, nil }