From 7539b12ae4047661944226afb73237ea6197c3b1 Mon Sep 17 00:00:00 2001 From: Brandon Wagner Date: Tue, 31 Oct 2023 16:54:29 -0400 Subject: [PATCH] fix: deprioritize metal-24xl and metal-48xl in addition to non-suffixed metal instance types (#4994) --- pkg/providers/instance/instance.go | 3 ++- pkg/providers/instancetype/nodeclass_test.go | 2 +- pkg/providers/instancetype/nodetemplate_test.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/providers/instance/instance.go b/pkg/providers/instance/instance.go index 3721dd38a8b9..2dd6b789f38c 100644 --- a/pkg/providers/instance/instance.go +++ b/pkg/providers/instance/instance.go @@ -20,6 +20,7 @@ import ( "fmt" "math" "sort" + "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -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)]) || diff --git a/pkg/providers/instancetype/nodeclass_test.go b/pkg/providers/instancetype/nodeclass_test.go index 563caed3cff2..620a01e03149 100644 --- a/pkg/providers/instancetype/nodeclass_test.go +++ b/pkg/providers/instancetype/nodeclass_test.go @@ -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()) } } }) diff --git a/pkg/providers/instancetype/nodetemplate_test.go b/pkg/providers/instancetype/nodetemplate_test.go index 890e4d387f17..0edb10700d77 100644 --- a/pkg/providers/instancetype/nodetemplate_test.go +++ b/pkg/providers/instancetype/nodetemplate_test.go @@ -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()) } } })