Skip to content
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

treat amd64 the same as x86_64 #35

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Filter Flags:
-z, --availability-zones strings Availability zones or zone ids to check EC2 capacity offered in specific AZs
--baremetal Bare Metal instance types (.metal instances)
-b, --burst-support Burstable instance types
-a, --cpu-architecture string CPU architecture [x86_64, i386, or arm64]
-a, --cpu-architecture string CPU architecture [x86_64/amd64, i386, or arm64]
--current-generation Current generation instance types (explicitly set this to false to not return current generation instance types)
--deny-list string List of instance types which should be excluded w/ regex syntax (Example: m[1-2]\.*)
-e, --ena-support Instance types where ENA is supported or required
Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Full docs can be found at github.com/aws/amazon-` + binName
cli.IntMinMaxRangeFlags(vcpus, cli.StringMe("c"), nil, "Number of vcpus available to the instance type.")
cli.IntMinMaxRangeFlags(memory, cli.StringMe("m"), nil, "Amount of Memory available in MiB (Example: 4096)")
cli.RatioFlag(vcpusToMemoryRatio, nil, nil, "The ratio of vcpus to memory in MiB. (Example: 1:2)")
cli.StringFlag(cpuArchitecture, cli.StringMe("a"), nil, "CPU architecture [x86_64, i386, or arm64]", nil)
cli.StringFlag(cpuArchitecture, cli.StringMe("a"), nil, "CPU architecture [x86_64/amd64, i386, or arm64]", nil)
cli.IntMinMaxRangeFlags(gpus, cli.StringMe("g"), nil, "Total Number of GPUs (Example: 4)")
cli.IntMinMaxRangeFlags(gpuMemoryTotal, nil, nil, "Number of GPUs' total memory in MiB (Example: 4096)")
cli.StringFlag(placementGroupStrategy, nil, nil, "Placement group strategy: [cluster, partition, spread]", nil)
Expand Down
7 changes: 7 additions & 0 deletions pkg/selector/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const (
networkPerformance = "networkPerformance"
allowList = "allowList"
denyList = "denyList"

cpuArchitectureAMD64 = "amd64"
cpuArchitectureX8664 = "x86_64"
)

// New creates an instance of Selector provided an aws session
Expand Down Expand Up @@ -149,6 +152,10 @@ func (itf Selector) rawFilter(filters Filters) ([]*ec2.InstanceTypeInfo, error)
}
}

if filters.CPUArchitecture != nil && *filters.CPUArchitecture == cpuArchitectureAMD64 {
*filters.CPUArchitecture = cpuArchitectureX8664
}

if filters.AvailabilityZones != nil {
locations = *filters.AvailabilityZones
} else if filters.Region != nil {
Expand Down
15 changes: 15 additions & 0 deletions pkg/selector/selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,18 @@ func TestFilter_AllowAndDenyList(t *testing.T) {
h.Ok(t, err)
h.Assert(t, len(results) == 4, "Allow/Deny List Regex: 'c4.large' should return 4 instance types matching the regex but returned %d", len(results))
}

func TestFilter_X8664_AMD64(t *testing.T) {
ec2Mock := setupMock(t, describeInstanceTypesPages, "t3_micro.json")
itf := selector.Selector{
EC2: ec2Mock,
}
filters := selector.Filters{
CPUArchitecture: aws.String("amd64"),
}
results, err := itf.Filter(filters)
h.Ok(t, err)
log.Println(results)
h.Assert(t, len(results) == 1, "Should only return 1 instance type with x86_64/amd64 cpu architecture")
h.Assert(t, results[0] == "t3.micro", "Should return t3.micro, got %s instead", results[0])
}
2 changes: 1 addition & 1 deletion pkg/selector/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type Filters struct {
Burstable *bool

// CPUArchitecture of the EC2 instance type
// Possible values are: x86_64 or arm64
// Possible values are: x86_64/amd64 or arm64
CPUArchitecture *string

// CurrentGeneration returns the latest generation of instance types
Expand Down