@@ -21,6 +21,8 @@ import (
21
21
"sync/atomic"
22
22
23
23
"k8s.io/apimachinery/pkg/api/resource"
24
+ "k8s.io/apimachinery/pkg/util/sets"
25
+ "sigs.k8s.io/controller-runtime/pkg/log"
24
26
"sigs.k8s.io/karpenter/pkg/scheduling"
25
27
26
28
awscache "github.com/aws/karpenter-provider-aws/pkg/cache"
@@ -32,14 +34,12 @@ import (
32
34
"github.com/mitchellh/hashstructure/v2"
33
35
"github.com/patrickmn/go-cache"
34
36
corev1 "k8s.io/api/core/v1"
35
- "sigs.k8s.io/controller-runtime/pkg/log"
36
37
karpv1 "sigs.k8s.io/karpenter/pkg/apis/v1"
37
38
38
39
"github.com/aws/aws-sdk-go-v2/aws"
39
40
"github.com/aws/aws-sdk-go-v2/service/ec2"
40
41
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
41
42
"github.com/samber/lo"
42
- "k8s.io/apimachinery/pkg/util/sets"
43
43
44
44
v1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1"
45
45
sdk "github.com/aws/karpenter-provider-aws/pkg/aws"
@@ -157,12 +157,24 @@ func (p *DefaultProvider) List(ctx context.Context, nodeClass *v1.EC2NodeClass)
157
157
// date capacity information. Rather than incurring a cache miss each time an instance is launched into a reserved
158
158
// offering (or terminated), offerings are injected to the cached instance types on each call. Note that on-demand and
159
159
// spot offerings are still cached - only reserved offerings are generated each time.
160
- return p .offeringProvider .InjectOfferings (
160
+ instanceTypesWithOfferings := p .offeringProvider .InjectOfferings (
161
161
ctx ,
162
162
instanceTypes ,
163
163
nodeClass ,
164
164
p .allZones ,
165
- ), nil
165
+ )
166
+
167
+ // Filter instance types that don't have compatible AMIs to prevent architecture mismatches
168
+ filteredInstanceTypes := amifamily .FilterInstanceTypesByAMICompatibility (instanceTypesWithOfferings , nodeClass .Status .AMIs )
169
+ if len (filteredInstanceTypes ) == 0 {
170
+ log .FromContext (ctx ).WithValues (
171
+ "nodeclass" , nodeClass .Name ,
172
+ "ami-count" , len (nodeClass .Status .AMIs ),
173
+ "instance-type-count" , len (instanceTypesWithOfferings ),
174
+ ).V (4 ).Info ("no instance types are compatible with available AMIs, check NodePool and NodeClass architecture requirements" )
175
+ }
176
+
177
+ return filteredInstanceTypes , nil
166
178
}
167
179
168
180
func (p * DefaultProvider ) resolveInstanceTypes (
0 commit comments