diff --git a/cmd/main.go b/cmd/main.go index e2490d07..7c248f00 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -60,6 +60,8 @@ const ( vcpus = "vcpus" memory = "memory" vcpusToMemoryRatio = "vcpus-to-memory-ratio" + defaultCores = "default-cores" + defaultThreadsPerCore = "default-threads-per-core" cpuArchitecture = "cpu-architecture" cpuManufacturer = "cpu-manufacturer" gpus = "gpus" @@ -164,6 +166,8 @@ Full docs can be found at github.com/aws/amazon-` + binName // Filter Flags - These will be grouped at the top of the help flags cli.Int32MinMaxRangeFlags(vcpus, cli.StringMe("c"), nil, "Number of vcpus available to the instance type.") + cli.Int32MinMaxRangeFlags(defaultCores, cli.StringMe("p"), nil, "Number of real cores available to the instance type.") + cli.Int32MinMaxRangeFlags(defaultThreadsPerCore, nil, nil, "Default threads per core (i.e., hyperthreading).") cli.ByteQuantityMinMaxRangeFlags(memory, cli.StringMe("m"), nil, "Amount of Memory available (Example: 4 GiB)") cli.RatioFlag(vcpusToMemoryRatio, nil, nil, "The ratio of vcpus to GiBs of memory. (Example: 1:2)") cli.StringOptionsFlag(cpuArchitecture, cli.StringMe("a"), nil, "CPU architecture [x86_64/amd64, x86_64_mac, i386, or arm64]", []string{"x86_64", "x86_64_mac", "amd64", "i386", "arm64"}) @@ -370,6 +374,8 @@ Full docs can be found at github.com/aws/amazon-` + binName filters := selector.Filters{ VCpusRange: cli.Int32RangeMe(flags[vcpus]), + DefaultCores: cli.Int32RangeMe(flags[defaultCores]), + DefaultThreadsPerCore: cli.Int32RangeMe(flags[defaultThreadsPerCore]), MemoryRange: cli.ByteQuantityRangeMe(flags[memory]), VCpusToMemoryRatio: cli.Float64Me(flags[vcpusToMemoryRatio]), CPUArchitecture: cpuArchitectureFilterValue, diff --git a/pkg/selector/selector.go b/pkg/selector/selector.go index 897864c3..e11ac625 100644 --- a/pkg/selector/selector.go +++ b/pkg/selector/selector.go @@ -55,6 +55,8 @@ const ( rootDeviceType = "rootDeviceType" hibernationSupported = "hibernationSupported" vcpusRange = "vcpusRange" + defaultCores = "defaultCores" + defaultThreadsPerCore = "defaultThreadsPerCore" memoryRange = "memoryRange" gpuMemoryRange = "gpuMemoryRange" gpusRange = "gpusRange" @@ -317,6 +319,8 @@ func (itf Selector) prepareFilter(ctx context.Context, filters Filters, instance rootDeviceType: {filters.RootDeviceType, instanceTypeInfo.SupportedRootDeviceTypes}, hibernationSupported: {filters.HibernationSupported, instanceTypeInfo.HibernationSupported}, vcpusRange: {filters.VCpusRange, instanceTypeInfo.VCpuInfo.DefaultVCpus}, + defaultCores: {filters.DefaultCores, instanceTypeInfo.VCpuInfo.DefaultCores}, + defaultThreadsPerCore: {filters.DefaultThreadsPerCore, instanceTypeInfo.VCpuInfo.DefaultThreadsPerCore}, memoryRange: {filters.MemoryRange, instanceTypeInfo.MemoryInfo.SizeInMiB}, gpuMemoryRange: {filters.GpuMemoryRange, getTotalGpuMemory(instanceTypeInfo.GpuInfo)}, gpusRange: {filters.GpusRange, getTotalGpusCount(instanceTypeInfo.GpuInfo)}, diff --git a/pkg/selector/types.go b/pkg/selector/types.go index 60395ebc..95a1a62d 100644 --- a/pkg/selector/types.go +++ b/pkg/selector/types.go @@ -215,6 +215,12 @@ type Filters struct { // VCpusRange filter is a range of acceptable VCpus for the instance type VCpusRange *Int32RangeFilter + // DefaultCores filter is a range of acceptable real cores for the instance type + DefaultCores *Int32RangeFilter + + // DefaultThreadsPerCore is a range of acceptable threads per core + DefaultThreadsPerCore *Int32RangeFilter + // VcpusToMemoryRatio is a ratio of vcpus to memory expressed as a floating point VCpusToMemoryRatio *float64 diff --git a/test/e2e/run-test b/test/e2e/run-test index 74b6f5dd..e590cd81 100755 --- a/test/e2e/run-test +++ b/test/e2e/run-test @@ -93,6 +93,18 @@ params=( ) echo "${expected[*]}" | execute_test "24 VCPUs" "${params[@]}" +expected=(c7a.32xlarge m7a.32xlarge r7a.32xlarge) +params=( + "--vcpus=128 --default-cores=128" +) +echo "${expected[*]}" | execute_test "128 vCPUs and 128 cores" "${params[@]}" + +expected=(c6a.metal m6a.metal r6a.metal) +params=( + "--vcpus=192 --default-cores=96 --baremetal" +) +echo "${expected[*]}" | execute_test "192 vCPUs and 96 cores and baremetal" "${params[@]}" + expected=(g2.8xlarge g3.16xlarge g4dn.12xlarge p3.8xlarge) params=( "--gpus=4"