Skip to content

Commit

Permalink
fix: de-prioritize bare metal instance types (#2119)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzneal authored Jul 13, 2022
1 parent b1d6dd9 commit c3b04a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/cloudprovider/aws/instancetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func compressInstanceType(instanceType *ec2.InstanceTypeInfo) *ec2.InstanceTypeI
InstanceStorageInfo: instanceType.InstanceStorageInfo,
MemoryInfo: &ec2.MemoryInfo{SizeInMiB: instanceType.MemoryInfo.SizeInMiB},
ProcessorInfo: &ec2.ProcessorInfo{SupportedArchitectures: instanceType.ProcessorInfo.SupportedArchitectures},
BareMetal: instanceType.BareMetal,
NetworkInfo: &ec2.NetworkInfo{
Ipv4AddressesPerInterface: instanceType.NetworkInfo.Ipv4AddressesPerInterface,
MaximumNetworkInterfaces: instanceType.NetworkInfo.MaximumNetworkInterfaces,
Expand Down
22 changes: 21 additions & 1 deletion pkg/cloudprovider/aws/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,26 @@ var _ = Describe("Allocation", func() {
ExpectNotScheduled(ctx, env.Client, pod)
}
})
It("should de-prioritize metal", func() {
ExpectApplied(ctx, env.Client, provisioner)
for _, pod := range ExpectProvisioned(ctx, env.Client, controller,
test.UnschedulablePod(test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
},
})) {
ExpectScheduled(ctx, env.Client, pod)
}
Expect(fakeEC2API.CalledWithCreateFleetInput.Len()).To(Equal(1))
call := fakeEC2API.CalledWithCreateFleetInput.Pop()
_ = call
for _, ltc := range call.LaunchTemplateConfigs {
for _, ovr := range ltc.Overrides {
Expect(strings.HasSuffix(aws.StringValue(ovr.InstanceType), "metal")).To(BeFalse())
}
}
})
It("should launch on metal", func() {
ExpectApplied(ctx, env.Client, provisioner)
for _, pod := range ExpectProvisioned(ctx, env.Client, controller,
Expand Down Expand Up @@ -477,7 +497,7 @@ var _ = Describe("Allocation", func() {
Expect(node.Labels).To(HaveKeyWithValue(v1.LabelInstanceTypeStable, "inf1.6xlarge"))
})
It("should launch on-demand capacity if flexible to both spot and on-demand, but spot if unavailable", func() {
safeSpotFallbackThreshold = 5
safeSpotFallbackThreshold = 4
fakeEC2API.DescribeInstanceTypesPagesWithContext(ctx, &ec2.DescribeInstanceTypesInput{}, func(dito *ec2.DescribeInstanceTypesOutput, b bool) bool {
for _, it := range dito.InstanceTypes {
fakeEC2API.InsufficientCapacityPools.Add(fake.CapacityPool{CapacityType: v1alpha1.CapacityTypeSpot, InstanceType: aws.StringValue(it.InstanceType), Zone: "test-zone-1a"})
Expand Down

0 comments on commit c3b04a5

Please sign in to comment.