Skip to content

Bypass instance limit check if AWS's API doesn't provide the information #1439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/lib/aws/servicequotas.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/servicequotas"
"github.com/cortexlabs/cortex/pkg/lib/errors"
"github.com/cortexlabs/cortex/pkg/lib/pointer"
"github.com/cortexlabs/cortex/pkg/lib/sets/strset"
)

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

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

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

if cpuLimit == 0 {
if cpuLimit != nil && *cpuLimit == 0 {
return ErrorInstanceTypeLimitIsZero(instanceType, c.Region)
}

Expand Down