Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Explicitly define all components that will be used for Instance type discovery #5854

Merged
merged 21 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0677fcf
docs: Reword AMI tasks to options (#5815)
chrisnegus Mar 9, 2024
40e1e4a
Merge branch 'main' of https://github.com/aws/karpenter-provider-aws
engedaam Mar 12, 2024
8b9d231
Merge branch 'main' of https://github.com/aws/karpenter-provider-aws
engedaam Mar 13, 2024
fdef8bb
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
561618d
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
ab6c07d
docs: Reword AMI tasks to options (#5815)
chrisnegus Mar 9, 2024
5aeaac7
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
2e10b10
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
c421858
Merge branch 'updeate-instancetype-signture' of https://github.com/en…
engedaam Mar 27, 2024
d2b40ae
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
47b6339
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
d7af783
Merge branch 'updeate-instancetype-signture' of https://github.com/en…
engedaam Mar 27, 2024
919ef70
docs: Reword AMI tasks to options (#5815)
chrisnegus Mar 9, 2024
36e9c6a
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
8f8bb12
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
15f67fd
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
87cfb83
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
fcd065c
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
fcb590f
Explicitly Call each signature for instance types
engedaam Mar 9, 2024
9ef3eba
Merge branch 'updeate-instancetype-signture' of https://github.com/en…
engedaam Mar 27, 2024
fea1467
Merge branch 'main' of https://github.com/aws/karpenter-provider-aws …
engedaam Apr 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pkg/providers/instancetype/instancetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import (

"sigs.k8s.io/karpenter/pkg/cloudprovider"
"sigs.k8s.io/karpenter/pkg/utils/pretty"

"github.com/aws/karpenter-provider-aws/pkg/providers/amifamily"
)

const (
Expand Down Expand Up @@ -104,6 +106,13 @@ func (p *Provider) List(ctx context.Context, kc *corev1beta1.KubeletConfiguratio
return aws.StringValue(s.AvailabilityZone)
})...)

if kc == nil {
engedaam marked this conversation as resolved.
Show resolved Hide resolved
kc = &corev1beta1.KubeletConfiguration{}
}
if nodeClass == nil {
nodeClass = &v1beta1.EC2NodeClass{}
}

// Compute fully initialized instance types hash key
subnetZonesHash, _ := hashstructure.Hash(subnetZones, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true})
kcHash, _ := hashstructure.Hash(kc, hashstructure.FormatV2, &hashstructure.HashOptions{SlicesAsSets: true})
Expand Down Expand Up @@ -133,6 +142,7 @@ func (p *Provider) List(ctx context.Context, kc *corev1beta1.KubeletConfiguratio
if p.cm.HasChanged("zones", allZones) {
logging.FromContext(ctx).With("zones", allZones.UnsortedList()).Debugf("discovered zones")
}
amiFamily := amifamily.GetAMIFamily(nodeClass.Spec.AMIFamily, &amifamily.Options{})
result := lo.Map(instanceTypes, func(i *ec2.InstanceTypeInfo, _ int) *cloudprovider.InstanceType {
instanceTypeVCPU.With(prometheus.Labels{
instanceTypeLabel: *i.InstanceType,
Expand All @@ -141,7 +151,14 @@ func (p *Provider) List(ctx context.Context, kc *corev1beta1.KubeletConfiguratio
instanceTypeLabel: *i.InstanceType,
}).Set(float64(aws.Int64Value(i.MemoryInfo.SizeInMiB) * 1024 * 1024))

return NewInstanceType(ctx, i, kc, p.region, nodeClass, p.createOfferings(ctx, i, instanceTypeOfferings[aws.StringValue(i.InstanceType)], allZones, subnetZones))
// !!! Important !!!
// Any changes to the values passed into the NewInstanceType method will require making updates to the cache key
// so that Karpenter is able to cache the set of InstanceTypes based on values that alter the set of instance types
// !!! Important !!!
return NewInstanceType(ctx, i, p.region,
nodeClass.Spec.BlockDeviceMappings, nodeClass.Spec.InstanceStorePolicy,
kc.MaxPods, kc.PodsPerCore, kc.KubeReserved, kc.SystemReserved, kc.EvictionHard, kc.EvictionSoft,
amiFamily, p.createOfferings(ctx, i, instanceTypeOfferings[aws.StringValue(i.InstanceType)], allZones, subnetZones))
})
p.cache.SetDefault(key, result)
return result, nil
Expand Down
Loading
Loading