From 79e05194d220d42bcec55a0838b301c6c1bc00c3 Mon Sep 17 00:00:00 2001 From: Jason Deal Date: Wed, 30 Oct 2024 12:35:13 -0700 Subject: [PATCH] fix: correctly check for latest alias --- .../templates/karpenter.k8s.aws_ec2nodeclasses.yaml | 2 +- pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml | 2 +- pkg/providers/amifamily/ami.go | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/charts/karpenter-crd/templates/karpenter.k8s.aws_ec2nodeclasses.yaml b/charts/karpenter-crd/templates/karpenter.k8s.aws_ec2nodeclasses.yaml index 5b1b6f8eadce..e898acee9a62 100644 --- a/charts/karpenter-crd/templates/karpenter.k8s.aws_ec2nodeclasses.yaml +++ b/charts/karpenter-crd/templates/karpenter.k8s.aws_ec2nodeclasses.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4 + controller-gen.kubebuilder.io/version: v0.16.5 name: ec2nodeclasses.karpenter.k8s.aws spec: group: karpenter.k8s.aws diff --git a/pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml b/pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml index c942189eb616..48cfade76afd 100644 --- a/pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml +++ b/pkg/apis/crds/karpenter.k8s.aws_ec2nodeclasses.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4 + controller-gen.kubebuilder.io/version: v0.16.5 name: ec2nodeclasses.karpenter.k8s.aws spec: group: karpenter.k8s.aws diff --git a/pkg/providers/amifamily/ami.go b/pkg/providers/amifamily/ami.go index 871559d71e07..2d41eb8e2838 100644 --- a/pkg/providers/amifamily/ami.go +++ b/pkg/providers/amifamily/ami.go @@ -72,7 +72,10 @@ func (p *DefaultProvider) List(ctx context.Context, nodeClass *v1.EC2NodeClass) // Discover deprecated AMIs if automatic AMI discovery and upgrade is enabled. This ensures we'll be able to // provision in the event of an EKS optimized AMI being deprecated. includeDeprecated := lo.ContainsBy(nodeClass.Spec.AMISelectorTerms, func(term v1.AMISelectorTerm) bool { - return term.Alias == "latest" + if term.Alias == "" { + return false + } + return v1.AMIVersionFromAlias(term.Alias) == "latest" }) amis, err := p.amis(ctx, queries, includeDeprecated) if err != nil {