From e35e48d01851c29df9814f2acfa817f277100759 Mon Sep 17 00:00:00 2001 From: Amanuel Engeda <74629455+engedaam@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:47:40 -0700 Subject: [PATCH] chore: Update liniting for release-v0.34.x (#6930) --- hack/docgen.sh | 10 +++++----- .../compatibility-karpenter.yaml | 0 .../main.go} | 4 ++-- .../main.go} | 0 .../main.go} | 0 hack/docs/{metrics_gen_docs.go => metrics/main.go} | 0 .../main.go} | 0 pkg/apis/v1beta1/ec2nodeclass_conversion.go | 2 ++ pkg/providers/amifamily/ami.go | 2 +- pkg/providers/amifamily/resolver.go | 3 +++ pkg/providers/instance/instance.go | 6 +++--- pkg/test/environment.go | 4 ++-- website/content/en/preview/upgrading/compatibility.md | 4 ++-- 13 files changed, 20 insertions(+), 15 deletions(-) rename hack/docs/{ => compatibilitymatrix}/compatibility-karpenter.yaml (100%) rename hack/docs/{compatibilitymetrix_gen_docs.go => compatibilitymatrix/main.go} (95%) rename hack/docs/{configuration_gen_docs.go => configuration/main.go} (100%) rename hack/docs/{instancetypes_gen_docs.go => instancetypes/main.go} (100%) rename hack/docs/{metrics_gen_docs.go => metrics/main.go} (100%) rename hack/docs/{version_compatibility.go => versioncompatibility/main.go} (100%) diff --git a/hack/docgen.sh b/hack/docgen.sh index 037114698363..385b6cdb3a4a 100755 --- a/hack/docgen.sh +++ b/hack/docgen.sh @@ -4,13 +4,13 @@ set -euo pipefail compatibilitymatrix() { # versionCount is the number of K8s versions to display in the compatibility matrix versionCount=7 - go run hack/docs/version_compatibility.go hack/docs/compatibility-karpenter.yaml "$(git describe --exact-match --tags || echo "no tag")" - go run hack/docs/compatibilitymetrix_gen_docs.go website/content/en/preview/upgrading/compatibility.md hack/docs/compatibility-karpenter.yaml $versionCount + go run hack/docs/versioncompatibility/main.go hack/docs/compatibilitymatrix/compatibility-karpenter.yaml "$(git describe --exact-match --tags || echo "no tag")" + go run hack/docs/compatibilitymatrix/main.go website/content/en/preview/upgrading/compatibility.md hack/docs/compatibilitymatrix/compatibility-karpenter.yaml $versionCount } compatibilitymatrix -go run hack/docs/metrics_gen_docs.go pkg/ ${KARPENTER_CORE_DIR}/pkg website/content/en/preview/reference/metrics.md -go run hack/docs/instancetypes_gen_docs.go website/content/en/preview/reference/instance-types.md -go run hack/docs/configuration_gen_docs.go website/content/en/preview/reference/settings.md +go run hack/docs/metrics/main.go pkg/ ${KARPENTER_CORE_DIR}/pkg website/content/en/preview/reference/metrics.md +go run hack/docs/instancetypes/main.go website/content/en/preview/reference/instance-types.md +go run hack/docs/configuration/main.go website/content/en/preview/reference/settings.md cd charts/karpenter && helm-docs diff --git a/hack/docs/compatibility-karpenter.yaml b/hack/docs/compatibilitymatrix/compatibility-karpenter.yaml similarity index 100% rename from hack/docs/compatibility-karpenter.yaml rename to hack/docs/compatibilitymatrix/compatibility-karpenter.yaml diff --git a/hack/docs/compatibilitymetrix_gen_docs.go b/hack/docs/compatibilitymatrix/main.go similarity index 95% rename from hack/docs/compatibilitymetrix_gen_docs.go rename to hack/docs/compatibilitymatrix/main.go index d5f4b983f6c2..3c5b0816a1af 100644 --- a/hack/docs/compatibilitymetrix_gen_docs.go +++ b/hack/docs/compatibilitymatrix/main.go @@ -32,8 +32,8 @@ func main() { os.Exit(1) } - genStart := "[comment]: <> (the content below is generated from hack/docs/compataiblitymetrix_gen_docs.go)" - genEnd := "[comment]: <> (end docs generated content from hack/docs/compataiblitymetrix_gen_docs.go)" + genStart := "[comment]: <> (the content below is generated from hack/docs/compatibilitymatrix/main.go)" + genEnd := "[comment]: <> (end docs generated content from hack/docs/compatibilitymatrix/main.go)" startDocSections := strings.Split(string(mdFile), genStart) if len(startDocSections) != 2 { log.Fatalf("expected one generated comment block start but got %d", len(startDocSections)-1) diff --git a/hack/docs/configuration_gen_docs.go b/hack/docs/configuration/main.go similarity index 100% rename from hack/docs/configuration_gen_docs.go rename to hack/docs/configuration/main.go diff --git a/hack/docs/instancetypes_gen_docs.go b/hack/docs/instancetypes/main.go similarity index 100% rename from hack/docs/instancetypes_gen_docs.go rename to hack/docs/instancetypes/main.go diff --git a/hack/docs/metrics_gen_docs.go b/hack/docs/metrics/main.go similarity index 100% rename from hack/docs/metrics_gen_docs.go rename to hack/docs/metrics/main.go diff --git a/hack/docs/version_compatibility.go b/hack/docs/versioncompatibility/main.go similarity index 100% rename from hack/docs/version_compatibility.go rename to hack/docs/versioncompatibility/main.go diff --git a/pkg/apis/v1beta1/ec2nodeclass_conversion.go b/pkg/apis/v1beta1/ec2nodeclass_conversion.go index 0f9b330138dc..b10d91cace27 100644 --- a/pkg/apis/v1beta1/ec2nodeclass_conversion.go +++ b/pkg/apis/v1beta1/ec2nodeclass_conversion.go @@ -2,7 +2,9 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pkg/providers/amifamily/ami.go b/pkg/providers/amifamily/ami.go index 650942f2cd54..9f7b9a014faa 100644 --- a/pkg/providers/amifamily/ami.go +++ b/pkg/providers/amifamily/ami.go @@ -102,7 +102,7 @@ func NewProvider(versionProvider *version.Provider, ssmProvider ssm.Provider, ec cache: cache, ec2api: ec2api, cm: pretty.NewChangeMonitor(), - ssmProvider: ssmProvider, + ssmProvider: ssmProvider, versionProvider: versionProvider, } } diff --git a/pkg/providers/amifamily/resolver.go b/pkg/providers/amifamily/resolver.go index 57fc079004f7..6d4757dea8a5 100644 --- a/pkg/providers/amifamily/resolver.go +++ b/pkg/providers/amifamily/resolver.go @@ -216,6 +216,9 @@ func (r Resolver) resolveLaunchTemplate(nodeClass *v1beta1.EC2NodeClass, nodeCla } } if kubeletConfig.MaxPods == nil { + // nolint:gosec + // We know that it's not possible to have values that would overflow int32 here since we control + // the maxPods values that we pass in here kubeletConfig.MaxPods = lo.ToPtr(int32(maxPods)) } resolved := &LaunchTemplate{ diff --git a/pkg/providers/instance/instance.go b/pkg/providers/instance/instance.go index 5d44e19503d0..ce2668358adb 100644 --- a/pkg/providers/instance/instance.go +++ b/pkg/providers/instance/instance.go @@ -16,7 +16,7 @@ package instance import ( "context" - "errors" + stderrors "errors" "fmt" "math" "sort" @@ -233,7 +233,7 @@ func (p *Provider) launchInstance(ctx context.Context, nodeClass *v1beta1.EC2Nod return nil, fmt.Errorf("creating fleet %w", err) } var reqFailure awserr.RequestFailure - if errors.As(err, &reqFailure) { + if stderrors.As(err, &reqFailure) { return nil, fmt.Errorf("creating fleet %w (%s)", err, reqFailure.RequestID()) } return nil, fmt.Errorf("creating fleet %w", err) @@ -506,7 +506,7 @@ func combineFleetErrors(errors []*ec2.CreateFleetError) (errs error) { unique.Insert(fmt.Sprintf("%s: %s", aws.StringValue(err.ErrorCode), aws.StringValue(err.ErrorMessage))) } for errorCode := range unique { - errs = multierr.Append(errs, fmt.Errorf(errorCode)) + errs = multierr.Append(errs, stderrors.New(errorCode)) } // If all the Fleet errors are ICE errors then we should wrap the combined error in the generic ICE error iceErrorCount := lo.CountBy(errors, func(err *ec2.CreateFleetError) bool { return awserrors.IsUnfulfillableCapacity(err) }) diff --git a/pkg/test/environment.go b/pkg/test/environment.go index 04008636bc8c..237da4f5500e 100644 --- a/pkg/test/environment.go +++ b/pkg/test/environment.go @@ -66,7 +66,7 @@ type Environment struct { SubnetCache *cache.Cache SecurityGroupCache *cache.Cache InstanceProfileCache *cache.Cache - SSMProviderCache *cache.Cache + SSMProviderCache *cache.Cache // Providers InstanceTypesProvider *instancetype.Provider @@ -147,7 +147,7 @@ func NewEnvironment(ctx context.Context, env *coretest.Environment) *Environment SecurityGroupCache: securityGroupCache, InstanceProfileCache: instanceProfileCache, UnavailableOfferingsCache: unavailableOfferingsCache, - SSMProviderCache: ssmProviderCache, + SSMProviderCache: ssmProviderCache, InstanceTypesProvider: instanceTypesProvider, InstanceProvider: instanceProvider, diff --git a/website/content/en/preview/upgrading/compatibility.md b/website/content/en/preview/upgrading/compatibility.md index e4cbdee8c5c9..24de2fb48ec0 100644 --- a/website/content/en/preview/upgrading/compatibility.md +++ b/website/content/en/preview/upgrading/compatibility.md @@ -13,13 +13,13 @@ Before you begin upgrading Karpenter, consider Karpenter compatibility issues re ## Compatibility Matrix -[comment]: <> (the content below is generated from hack/docs/compataiblitymetrix_gen_docs.go) +[comment]: <> (the content below is generated from hack/docs/compatibilitymatrix/main.go) | KUBERNETES | 1.23 | 1.24 | 1.25 | 1.26 | 1.27 | 1.28 | |------------|---------|---------|---------|---------|---------|---------| | karpenter | 0.21.x+ | 0.21.x+ | 0.25.x+ | 0.28.x+ | 0.28.x+ | 0.31.x+ | -[comment]: <> (end docs generated content from hack/docs/compataiblitymetrix_gen_docs.go) +[comment]: <> (end docs generated content from hack/docs/compatibilitymatrix/main.go) {{% alert title="Note" color="warning" %}} The Ubuntu EKS optimized AMI has moved from 20.04 to 22.04 for Kubernetes 1.29+. This new AMI version is __not currently__ supported for users relying on AMI auto-discovery with the Ubuntu AMI family. More details can be found in this [GitHub issue](https://github.com/aws/karpenter-provider-aws/issues/5572). Please review this issue before upgrading to Kubernetes 1.29 if you are using the Ubuntu AMI family. Upgrading to 1.29 without making any changes to your EC2NodeClass will result in Karpenter being unable to create new nodes.