Skip to content

Commit

Permalink
chore: Use AMI IDs in the logs for AMI discovery (aws#6220)
Browse files Browse the repository at this point in the history
  • Loading branch information
engedaam authored May 20, 2024
1 parent 30d12d2 commit 94bedac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pkg/providers/amifamily/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ func (p *DefaultProvider) List(ctx context.Context, nodeClass *v1beta1.EC2NodeCl
}
}
amis.Sort()
if p.cm.HasChanged(fmt.Sprintf("amis/%s", nodeClass.Name), amis) {
logging.FromContext(ctx).With("ids", amis, "count", len(amis)).Debugf("discovered amis")
uniqueAMIs := lo.Uniq(lo.Map(amis, func(a AMI, _ int) string { return a.AmiID }))
if p.cm.HasChanged(fmt.Sprintf("amis/%s", nodeClass.Name), uniqueAMIs) {
logging.FromContext(ctx).With(
"ids", uniqueAMIs).Debugf("discovered amis")
}
return amis, nil
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/providers/amifamily/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"k8s.io/apimachinery/pkg/api/resource"

corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1"
"sigs.k8s.io/karpenter/pkg/utils/pretty"

"github.com/aws/karpenter-provider-aws/pkg/apis/v1beta1"
"github.com/aws/karpenter-provider-aws/pkg/providers/amifamily/bootstrap"
Expand Down Expand Up @@ -127,7 +126,7 @@ func (r Resolver) Resolve(nodeClass *v1beta1.EC2NodeClass, nodeClaim *corev1beta
}
mappedAMIs := MapToInstanceTypes(instanceTypes, nodeClass.Status.AMIs)
if len(mappedAMIs) == 0 {
return nil, fmt.Errorf("no instance types satisfy requirements of amis %v", pretty.Slice(lo.Map(nodeClass.Status.AMIs, func(a v1beta1.AMI, _ int) string { return a.ID }), 25))
return nil, fmt.Errorf("no instance types satisfy requirements of amis %v", lo.Uniq(lo.Map(nodeClass.Status.AMIs, func(a v1beta1.AMI, _ int) string { return a.ID })))
}
var resolvedTemplates []*LaunchTemplate
for amiID, instanceTypes := range mappedAMIs {
Expand Down

0 comments on commit 94bedac

Please sign in to comment.