From b77f10a71993c2a38a65a197bb12eb63ff9b027f Mon Sep 17 00:00:00 2001 From: Brandon Wagner Date: Tue, 31 Oct 2023 14:31:25 -0400 Subject: [PATCH 1/4] fix: do not error on capacity-block capacity-type (#4991) --- pkg/providers/instancetype/instancetype.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/providers/instancetype/instancetype.go b/pkg/providers/instancetype/instancetype.go index 4e780e41fbf4..c67436000cf7 100644 --- a/pkg/providers/instancetype/instancetype.go +++ b/pkg/providers/instancetype/instancetype.go @@ -141,6 +141,9 @@ func (p *Provider) createOfferings(ctx context.Context, instanceType *ec2.Instan price, ok = p.pricingProvider.SpotPrice(*instanceType.InstanceType, zone) case ec2.UsageClassTypeOnDemand: price, ok = p.pricingProvider.OnDemandPrice(*instanceType.InstanceType) + case "capacity-block": + // ignore since karpenter doesn't support it yet, but do not log an unknown capacity type error + continue default: logging.FromContext(ctx).Errorf("Received unknown capacity type %s for instance type %s", capacityType, *instanceType.InstanceType) continue From 9b5350ddb49240e4a1de21ce39ea0b067cecab90 Mon Sep 17 00:00:00 2001 From: Brandon Wagner Date: Tue, 31 Oct 2023 16:54:29 -0400 Subject: [PATCH 2/4] 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 9b683849c285..6b86cfa060c9 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" @@ -485,7 +486,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 454604a34d53..b2e3ba306887 100644 --- a/pkg/providers/instancetype/nodeclass_test.go +++ b/pkg/providers/instancetype/nodeclass_test.go @@ -385,7 +385,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 b7cab2ed9c73..afc8486259fe 100644 --- a/pkg/providers/instancetype/nodetemplate_test.go +++ b/pkg/providers/instancetype/nodetemplate_test.go @@ -392,7 +392,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()) } } }) From 0ecfdc0736ee3cd897553568bd128099b9655e99 Mon Sep 17 00:00:00 2001 From: Jason Deal Date: Fri, 1 Dec 2023 10:18:40 -0800 Subject: [PATCH 3/4] chore: bump karpenter-core --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 553e58e1b5f1..7aa0838ef151 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/PuerkitoBio/goquery v1.8.1 github.com/avast/retry-go v3.0.0+incompatible github.com/aws/aws-sdk-go v1.45.15 - github.com/aws/karpenter-core v0.31.2 + github.com/aws/karpenter-core v0.31.3 github.com/aws/karpenter/tools/kompat v0.0.0-20230915222222-abfbf5fa3644 github.com/imdario/mergo v0.3.16 github.com/mitchellh/hashstructure/v2 v2.0.2 diff --git a/go.sum b/go.sum index 37e25c708254..9ef493524277 100644 --- a/go.sum +++ b/go.sum @@ -55,8 +55,8 @@ github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHS github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= github.com/aws/aws-sdk-go v1.45.15 h1:gYBTVSYuhXdatrLbsPaRgVcc637zzdgThWmsDRwXLOo= github.com/aws/aws-sdk-go v1.45.15/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/karpenter-core v0.31.2 h1:amhUzexn2drKXNOgjJR8TKFFcQRgXDRmp0CBVaOI39k= -github.com/aws/karpenter-core v0.31.2/go.mod h1:z5aEstzzERZMO2L0AkhxtBtaSI6yZ806XC9WSPgrHyM= +github.com/aws/karpenter-core v0.31.3 h1:sL2rYBEXZAJMityDltfXLOGRwR7R9Vj95iZhHlwUiNo= +github.com/aws/karpenter-core v0.31.3/go.mod h1:z5aEstzzERZMO2L0AkhxtBtaSI6yZ806XC9WSPgrHyM= github.com/aws/karpenter/tools/kompat v0.0.0-20230915222222-abfbf5fa3644 h1:M1fxGlOfvSqFYI01HL2zzvomy8e7LiTHk77KDuChWZQ= github.com/aws/karpenter/tools/kompat v0.0.0-20230915222222-abfbf5fa3644/go.mod h1:l/TIBsaCx/IrOr0Xvlj/cHLOf05QzuQKEZ1hx2XWmfU= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= From 74bf29c3af879864c5b138569a7953bed2d41e32 Mon Sep 17 00:00:00 2001 From: Jason Deal Date: Fri, 1 Dec 2023 11:17:10 -0800 Subject: [PATCH 4/4] update linter configs for CI --- .golangci.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.golangci.yaml b/.golangci.yaml index 3fc54e3d71a4..8a19aae9fc5d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -37,6 +37,14 @@ linters-settings: min-complexity: 11 govet: check-shadowing: true + revive: + rules: + - name: dot-imports + disabled: true + stylecheck: + dot-import-whitelist: + - "github.com/onsi/ginkgo/v2" + - "github.com/onsi/gomega" misspell: locale: US ignore-words: []