Skip to content

Commit 94e1a07

Browse files
committed
Review feedback
1 parent eba93c6 commit 94e1a07

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

pkg/providers/instance/instance.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,13 @@ func (p *DefaultProvider) updateUnavailableOfferingsCache(
445445
nodeClaim *karpv1.NodeClaim,
446446
instanceTypes []*cloudprovider.InstanceType,
447447
) {
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+
448455
if capacityType != karpv1.CapacityTypeReserved {
449456
for _, err := range errs {
450457
if awserrors.IsUnfulfillableCapacity(err) {
@@ -454,9 +461,6 @@ func (p *DefaultProvider) updateUnavailableOfferingsCache(
454461
p.unavailableOfferings.MarkCapacityTypeUnavailable(karpv1.CapacityTypeSpot)
455462
p.recorder.Publish(SpotServiceLinkedRoleCreationFailure(nodeClaim))
456463
}
457-
if awserrors.IsInsufficientFreeAddressesInSubnet(err) {
458-
p.unavailableOfferings.MarkAZUnavailable(*err.LaunchTemplateAndOverrides.Overrides.AvailabilityZone)
459-
}
460464
}
461465
return
462466
}

pkg/providers/instance/suite_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,16 @@ var _ = Describe("InstanceProvider", func() {
376376
Expect(corecloudprovider.IsInsufficientCapacityError(err)).To(BeTrue())
377377
Expect(instance).To(BeNil())
378378

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+
}
381390
})
382391
})

0 commit comments

Comments
 (0)