@@ -408,12 +408,15 @@ func (v *Validation) getPrioritizedInstanceTypes(ctx context.Context, nodeClass
408408 if err != nil {
409409 return nil , err
410410 }
411- // We fallback to the default instance type if the AMI family is Windows. Karpenter currently incorrectly marks certain instance
412- // types as Windows compatible, and dynamic instance type resolution may choose those instance types for the dry-run, even if they
411+
412+ // If there weren't any matching instance types, we should fallback to some defaults. There's an instance type included
413+ // for both x86_64 and arm64 architectures, ensuring that there will be a matching AMI. We also fallback to the default
414+ // instance types if the AMI family is Windows. Karpenter currently incorrectly marks certain instance types as Windows
415+ // compatible, and dynamic instance type resolution may choose those instance types for the dry-run, even if they
413416 // wouldn't be chosen due to cost in practice. This ensures the behavior matches that on Karpenter v1.3, preventing a
414417 // potential regression for Windows users.
415418 // Tracking issue: https://github.com/aws/karpenter-provider-aws/issues/7985
416- if lo .ContainsBy ([]string {
419+ if len ( instanceTypes ) == 0 || lo .ContainsBy ([]string {
417420 v1 .AMIFamilyWindows2019 ,
418421 v1 .AMIFamilyWindows2022 ,
419422 v1 .AMIFamilyWindows2025 ,
@@ -430,14 +433,19 @@ func (v *Validation) getPrioritizedInstanceTypes(ctx context.Context, nodeClass
430433 scheduling .NewRequirement (corev1 .LabelWindowsBuild , corev1 .NodeSelectorOpExists ),
431434 )... ),
432435 },
436+ {
437+ Name : string (ec2types .InstanceTypeM6gLarge ),
438+ Requirements : scheduling .NewRequirements (append (
439+ lo .Values (amifamily .VariantStandard .Requirements ()),
440+ scheduling .NewRequirement (corev1 .LabelArchStable , corev1 .NodeSelectorOpIn , karpv1 .ArchitectureArm64 ),
441+ scheduling .NewRequirement (corev1 .LabelOSStable , corev1 .NodeSelectorOpExists ),
442+ scheduling .NewRequirement (corev1 .LabelWindowsBuild , corev1 .NodeSelectorOpExists ),
443+ )... ),
444+ },
433445 }
434446 instanceTypes = getAMICompatibleInstanceTypes (instanceTypes , nodeClass )
435447 }
436448
437- if len (instanceTypes ) == 0 {
438- panic ("Could not select on any instance type during NodeClass validation" )
439- }
440-
441449 return instanceTypes , nil
442450}
443451
0 commit comments