Skip to content

Commit b1db1ee

Browse files
authored
Disallow instance types that aren't supported by NLB (#1436)
1 parent 471197e commit b1db1ee

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pkg/lib/aws/elb.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ import (
2020
"github.com/aws/aws-sdk-go/aws"
2121
"github.com/aws/aws-sdk-go/service/elbv2"
2222
"github.com/cortexlabs/cortex/pkg/lib/errors"
23+
"github.com/cortexlabs/cortex/pkg/lib/sets/strset"
2324
)
2425

26+
// https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-target-groups.html
27+
var NLBUnsupportedInstancePrefixes = strset.New("c1", "cc1", "cc2", "cg1", "cg2", "cr1", "g1", "g2", "hi1", "hs1", "m1", "m2", "m3", "t1")
28+
2529
// returns the the first load balancer which has all of the specified tags, or nil if no load balancers match
2630
func (c *Client) FindLoadBalancer(tags map[string]string) (*elbv2.LoadBalancer, error) {
2731
var loadBalancer *elbv2.LoadBalancer

pkg/types/clusterconfig/clusterconfig.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,11 @@ func checkCortexSupport(instanceMetadata aws.InstanceMetadata) error {
654654
return ErrorInstanceTypeTooSmall()
655655
}
656656

657+
instancePrefix := strings.Split(instanceMetadata.Type, ".")[0]
658+
if aws.NLBUnsupportedInstancePrefixes.Has(instancePrefix) {
659+
return ErrorInstanceTypeNotSupported(instanceMetadata.Type)
660+
}
661+
657662
if err := checkCNISupport(instanceMetadata.Type); err != nil {
658663
return err
659664
}

0 commit comments

Comments
 (0)