Skip to content
Open
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
8 changes: 8 additions & 0 deletions pkg/actuators/machine/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,14 @@ func getCPUOptionsRequest(providerConfig *machinev1beta1.AWSMachineProviderConfi
}
}

if providerConfig.CPUOptions.CoreCount != nil {
cpuOptions.CoreCount = providerConfig.CPUOptions.CoreCount
}

if providerConfig.CPUOptions.ThreadsPerCore != nil {
cpuOptions.ThreadsPerCore = providerConfig.CPUOptions.ThreadsPerCore
}

if *cpuOptions == (ec2.CpuOptionsRequest{}) {
return nil
}
Expand Down
50 changes: 50 additions & 0 deletions pkg/actuators/machine/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,56 @@ func TestGetCPUOptionsRequest(t *testing.T) {
},
expectedRequest: nil,
},
{
name: "with CoreCount set",
providerConfig: &machinev1beta1.AWSMachineProviderConfig{
CPUOptions: &machinev1beta1.CPUOptions{
CoreCount: ptr.To[int64](4),
},
},
expectedRequest: &ec2.CpuOptionsRequest{
CoreCount: aws.Int64(4),
},
},
{
name: "with ThreadsPerCore set",
providerConfig: &machinev1beta1.AWSMachineProviderConfig{
CPUOptions: &machinev1beta1.CPUOptions{
ThreadsPerCore: ptr.To[int64](1),
},
},
expectedRequest: &ec2.CpuOptionsRequest{
ThreadsPerCore: aws.Int64(1),
},
},
{
name: "with CoreCount and ThreadsPerCore set",
providerConfig: &machinev1beta1.AWSMachineProviderConfig{
CPUOptions: &machinev1beta1.CPUOptions{
CoreCount: ptr.To[int64](2),
ThreadsPerCore: ptr.To[int64](2),
},
},
expectedRequest: &ec2.CpuOptionsRequest{
CoreCount: aws.Int64(2),
ThreadsPerCore: aws.Int64(2),
},
},
{
name: "with all CPUOptions fields set",
providerConfig: &machinev1beta1.AWSMachineProviderConfig{
CPUOptions: &machinev1beta1.CPUOptions{
ConfidentialCompute: ptr.To(machinev1beta1.AWSConfidentialComputePolicySEVSNP),
CoreCount: ptr.To[int64](4),
ThreadsPerCore: ptr.To[int64](1),
},
},
expectedRequest: &ec2.CpuOptionsRequest{
AmdSevSnp: aws.String(ec2.AmdSevSnpSpecificationEnabled),
CoreCount: aws.Int64(4),
ThreadsPerCore: aws.Int64(1),
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.