-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support regions without m4 machines #1163
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,12 +23,15 @@ var ( | |
"cn-north-1": "Beijing", | ||
"cn-northwest-1": "Ningxia", | ||
"eu-central-1": "Frankfurt", | ||
"eu-north-1": "Stockholm", | ||
"eu-west-1": "Ireland", | ||
"eu-west-2": "London", | ||
"eu-west-3": "Paris", | ||
"sa-east-1": "São Paulo", | ||
"us-east-1": "N. Virginia", | ||
"us-east-2": "Ohio", | ||
"us-gov-east-1": "AWS GovCloud (US-East)", | ||
"us-gov-west-1": "AWS GovCloud (US-West)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You sure about this? The pricing API calls this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It does, but I have an entry for decoding that here. They use |
||
"us-west-1": "N. California", | ||
"us-west-2": "Oregon", | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Platform Tests | ||
|
||
This directory contains test suites checking per-platform assumptions. | ||
These tests require platform access that is not appropriate for platform-agnostic unit tests. | ||
The `t` directory name (unlike `tests`) allows us to share [the project `vendor` directory managed by `dep`](../docs/dev/dependencies.md#go). | ||
|
||
Platforms: | ||
|
||
* [aws](aws) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# AWS Tests | ||
|
||
This directory contains test suites checking AWS-specific assumptions. | ||
Run with: | ||
|
||
```console | ||
$ AWS_PROFILE=your-profile go test . | ||
``` | ||
|
||
or similar (it needs access to [your AWS credentials][credentials]). | ||
|
||
[credentials]: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package aws | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/pricing" | ||
awsutil "github.com/openshift/installer/pkg/asset/installconfig/aws" | ||
"github.com/openshift/installer/pkg/types/aws/defaults" | ||
"github.com/openshift/installer/pkg/types/aws/validation" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetDefaultInstanceClass(t *testing.T) { | ||
ssn, err := awsutil.GetSession() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
exists := struct{}{} | ||
instanceClasses := map[string]map[string]struct{}{} | ||
|
||
client := pricing.New(ssn, aws.NewConfig().WithRegion("us-east-1")) | ||
|
||
err = client.GetProductsPages( | ||
&pricing.GetProductsInput{ | ||
ServiceCode: aws.String("AmazonEC2"), | ||
Filters: []*pricing.Filter{ | ||
{ | ||
Field: aws.String("tenancy"), | ||
Type: aws.String("TERM_MATCH"), | ||
Value: aws.String("Shared"), | ||
}, | ||
{ | ||
Field: aws.String("productFamily"), | ||
Type: aws.String("TERM_MATCH"), | ||
Value: aws.String("Compute Instance"), | ||
}, | ||
{ | ||
Field: aws.String("operatingSystem"), | ||
Type: aws.String("TERM_MATCH"), | ||
Value: aws.String("Linux"), | ||
}, | ||
{ | ||
Field: aws.String("instanceFamily"), | ||
Type: aws.String("TERM_MATCH"), | ||
Value: aws.String("General purpose"), | ||
}, | ||
}, | ||
}, | ||
func(result *pricing.GetProductsOutput, lastPage bool) bool { | ||
for _, priceList := range result.PriceList { | ||
product := priceList["product"].(map[string]interface{}) | ||
attr := product["attributes"].(map[string]interface{}) | ||
location := attr["location"].(string) | ||
instanceType := attr["instanceType"].(string) | ||
instanceClassSlice := strings.Split(instanceType, ".") | ||
instanceClass := instanceClassSlice[0] | ||
_, ok := instanceClasses[location] | ||
if ok { | ||
instanceClasses[location][instanceClass] = exists | ||
} else { | ||
instanceClasses[location] = map[string]struct{}{instanceClass: exists} | ||
} | ||
} | ||
return !lastPage | ||
}, | ||
) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
regions := map[string]string{ // seed with locations that don't match AWS's usual names | ||
"South America (Sao Paulo)": "sa-east-1", | ||
"AWS GovCloud (US)": "us-gov-west-1", | ||
} | ||
|
||
for location, classes := range instanceClasses { | ||
t.Run(location, func(t *testing.T) { | ||
region, ok := regions[location] | ||
if !ok { | ||
for slug, name := range validation.Regions { | ||
if strings.Contains(location, name) { | ||
regions[location] = slug | ||
region = slug | ||
break | ||
} | ||
} | ||
if region == "" { | ||
t.Fatal("not a recognized region") | ||
} | ||
} | ||
|
||
class := "" | ||
// ordered list of prefered instance classes | ||
for _, preferredClass := range []string{"m4", "m5"} { | ||
if _, ok := classes[preferredClass]; ok { | ||
class = preferredClass | ||
break | ||
} | ||
} | ||
if class == "" { | ||
t.Fatalf("does not support any preferred classes: %v", classes) | ||
} | ||
defaultClass := defaults.InstanceClass(region) | ||
assert.Equal(t, defaultClass, class) | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe RHEL has signed off on the M5 series. We will need to figure out which machine class we want to use as a fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought someone tested m5 somewhere :p. But whatever, it's easy to slot in a different alternative if you know what it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eric and Clayton think we should go with M5 for now. Ignore me!