Skip to content

Commit e01a9be

Browse files
authored
Bypass instance limit check if AWS's API doesn't provide the information (#1439)
1 parent 15e940e commit e01a9be

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/lib/aws/servicequotas.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/aws/aws-sdk-go/aws"
2424
"github.com/aws/aws-sdk-go/service/servicequotas"
2525
"github.com/cortexlabs/cortex/pkg/lib/errors"
26+
"github.com/cortexlabs/cortex/pkg/lib/pointer"
2627
"github.com/cortexlabs/cortex/pkg/lib/sets/strset"
2728
)
2829

@@ -42,7 +43,7 @@ func (c *Client) VerifyInstanceQuota(instanceType string) error {
4243
instancePrefix = "standard"
4344
}
4445

45-
var cpuLimit int
46+
var cpuLimit *int
4647
err := c.ServiceQuotas().ListServiceQuotasPages(
4748
&servicequotas.ListServiceQuotasInput{
4849
ServiceCode: aws.String("ec2"),
@@ -62,7 +63,7 @@ func (c *Client) VerifyInstanceQuota(instanceType string) error {
6263
}
6364

6465
if strings.ToLower(*metricClass) == instancePrefix+"/ondemand" {
65-
cpuLimit = int(*quota.Value) // quota is specified in number of vCPU permitted per family
66+
cpuLimit = pointer.Int(int(*quota.Value)) // quota is specified in number of vCPU permitted per family
6667
return false
6768
}
6869
}
@@ -73,7 +74,7 @@ func (c *Client) VerifyInstanceQuota(instanceType string) error {
7374
return errors.WithStack(err)
7475
}
7576

76-
if cpuLimit == 0 {
77+
if cpuLimit != nil && *cpuLimit == 0 {
7778
return ErrorInstanceTypeLimitIsZero(instanceType, c.Region)
7879
}
7980

0 commit comments

Comments
 (0)