File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -445,6 +445,13 @@ func (p *DefaultProvider) updateUnavailableOfferingsCache(
445
445
nodeClaim * karpv1.NodeClaim ,
446
446
instanceTypes []* cloudprovider.InstanceType ,
447
447
) {
448
+ for _ , err := range errs {
449
+ zone := lo .FromPtr (err .LaunchTemplateAndOverrides .Overrides .AvailabilityZone )
450
+ if awserrors .IsInsufficientFreeAddressesInSubnet (err ) && zone != "" {
451
+ p .unavailableOfferings .MarkAZUnavailable (zone )
452
+ }
453
+ }
454
+
448
455
if capacityType != karpv1 .CapacityTypeReserved {
449
456
for _ , err := range errs {
450
457
if awserrors .IsUnfulfillableCapacity (err ) {
@@ -454,9 +461,6 @@ func (p *DefaultProvider) updateUnavailableOfferingsCache(
454
461
p .unavailableOfferings .MarkCapacityTypeUnavailable (karpv1 .CapacityTypeSpot )
455
462
p .recorder .Publish (SpotServiceLinkedRoleCreationFailure (nodeClaim ))
456
463
}
457
- if awserrors .IsInsufficientFreeAddressesInSubnet (err ) {
458
- p .unavailableOfferings .MarkAZUnavailable (* err .LaunchTemplateAndOverrides .Overrides .AvailabilityZone )
459
- }
460
464
}
461
465
return
462
466
}
Original file line number Diff line number Diff line change @@ -376,7 +376,16 @@ var _ = Describe("InstanceProvider", func() {
376
376
Expect (corecloudprovider .IsInsufficientCapacityError (err )).To (BeTrue ())
377
377
Expect (instance ).To (BeNil ())
378
378
379
- // We should have set the subnet used in the request as unavailable
380
- Expect (awsEnv .UnavailableOfferingsCache .IsUnavailable ("m5.xlarge" , "test-zone-1a" , "on-demand" )).To (BeTrue ())
379
+ // We should have set the zone used in the request as unavailable for all instance types
380
+ for _ , instance := range instanceTypes {
381
+ Expect (awsEnv .UnavailableOfferingsCache .IsUnavailable (ec2types .InstanceType (instance .Name ), "test-zone-1a" , "on-demand" )).To (BeTrue ())
382
+ }
383
+ // But we should not have set the other zones as unavailable
384
+ zones := []string {"test-zone-1b" , "test-zone-1c" }
385
+ for _ , zone := range zones {
386
+ for _ , instance := range instanceTypes {
387
+ Expect (awsEnv .UnavailableOfferingsCache .IsUnavailable (ec2types .InstanceType (instance .Name ), zone , "on-demand" )).To (BeFalse ())
388
+ }
389
+ }
381
390
})
382
391
})
You can’t perform that action at this time.
0 commit comments