Skip to content

Commit

Permalink
fix: deprioritize metal-24xl and metal-48xl in addition to non-suffix…
Browse files Browse the repository at this point in the history
…ed metal instance types (aws#4994)
  • Loading branch information
bwagner5 authored Oct 31, 2023
1 parent b0cb711 commit 7539b12
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/providers/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"math"
"sort"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
Expand Down Expand Up @@ -483,7 +484,7 @@ func filterExoticInstanceTypes(instanceTypes []*cloudprovider.InstanceType, isMa
for _, it := range instanceTypes {
// deprioritize metal even if our opinionated filter isn't applied due to something like an instance family
// requirement
if it.Requirements.Get(lo.Ternary(isMachine, v1alpha1.LabelInstanceSize, v1beta1.LabelInstanceSize)).Has("metal") {
if _, ok := lo.Find(it.Requirements.Get(lo.Ternary(isMachine, v1alpha1.LabelInstanceSize, v1beta1.LabelInstanceSize)).Values(), func(size string) bool { return strings.Contains(size, "metal") }); ok {
continue
}
if !resources.IsZero(it.Capacity[lo.Ternary(isMachine, v1alpha1.ResourceAWSNeuron, v1beta1.ResourceAWSNeuron)]) ||
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/instancetype/nodeclass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ var _ = Describe("NodeClass/InstanceTypes", func() {
call := awsEnv.EC2API.CreateFleetBehavior.CalledWithInput.Pop()
for _, ltc := range call.LaunchTemplateConfigs {
for _, ovr := range ltc.Overrides {
Expect(strings.HasSuffix(aws.StringValue(ovr.InstanceType), "metal")).To(BeFalse())
Expect(strings.Contains(aws.StringValue(ovr.InstanceType), "metal")).To(BeFalse())
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/instancetype/nodetemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ var _ = Describe("NodeTemplate/InstanceTypes", func() {
call := awsEnv.EC2API.CreateFleetBehavior.CalledWithInput.Pop()
for _, ltc := range call.LaunchTemplateConfigs {
for _, ovr := range ltc.Overrides {
Expect(strings.HasSuffix(aws.StringValue(ovr.InstanceType), "metal")).To(BeFalse())
Expect(strings.Contains(aws.StringValue(ovr.InstanceType), "metal")).To(BeFalse())
}
}
})
Expand Down

0 comments on commit 7539b12

Please sign in to comment.