in pkg/providers/instance/instance.go [643:712]
func (p *DefaultProvider) handleResponseErrors(ctx context.Context, instanceType *corecloudprovider.InstanceType, zone, capacityType string, err error) error {
if sdkerrors.LowPriorityQuotaHasBeenReached(err) {
// Mark in cache that spot quota has been reached for this subscription
p.unavailableOfferings.MarkSpotUnavailableWithTTL(ctx, SubscriptionQuotaReachedTTL)
log.FromContext(ctx).Error(err, "")
return fmt.Errorf("this subscription has reached the regional vCPU quota for spot (LowPriorityQuota). To scale beyond this limit, please review the quota increase process here: https://docs.microsoft.com/en-us/azure/azure-portal/supportability/low-priority-quota")
}
if sdkerrors.SKUFamilyQuotaHasBeenReached(err) {
// Subscription quota has been reached for this VM SKU, mark the instance type as unavailable in all zones available to the offering
// This will also update the TTL for an existing offering in the cache that is already unavailable
log.FromContext(ctx).Error(err, "")
for _, offering := range instanceType.Offerings {
if getOfferingCapacityType(offering) != capacityType {
continue
}
// If we have a quota limit of 0 vcpus, we mark the offerings unavailable for an hour.
// CPU limits of 0 are usually due to a subscription having no allocated quota for that instance type at all on the subscription.
if cpuLimitIsZero(err) {
p.unavailableOfferings.MarkUnavailableWithTTL(ctx, SubscriptionQuotaReachedReason, instanceType.Name, getOfferingZone(offering), capacityType, SubscriptionQuotaReachedTTL)
} else {
p.unavailableOfferings.MarkUnavailable(ctx, SubscriptionQuotaReachedReason, instanceType.Name, getOfferingZone(offering), capacityType)
}
}
return fmt.Errorf("subscription level %s vCPU quota for %s has been reached (may try provision an alternative instance type)", capacityType, instanceType.Name)
}
if sdkerrors.IsSKUNotAvailable(err) {
// https://aka.ms/azureskunotavailable: either not available for a location or zone, or out of capacity for Spot.
// We only expect to observe the Spot case, not location or zone restrictions, because:
// - SKUs with location restriction are already filtered out via sku.HasLocationRestriction
// - zonal restrictions are filtered out internally by sku.AvailabilityZones, and don't get offerings
skuNotAvailableTTL := SKUNotAvailableSpotTTL
err = fmt.Errorf("out of spot capacity for %s: %w", instanceType.Name, err)
if capacityType == karpv1.CapacityTypeOnDemand { // should not happen, defensive check
err = fmt.Errorf("unexpected SkuNotAvailable error for %s (on-demand): %w", instanceType.Name, err)
skuNotAvailableTTL = SKUNotAvailableOnDemandTTL // still mark all offerings as unavailable, but with a longer TTL
}
// mark the instance type as unavailable for all offerings/zones for the capacity type
for _, offering := range instanceType.Offerings {
if getOfferingCapacityType(offering) != capacityType {
continue
}
p.unavailableOfferings.MarkUnavailableWithTTL(ctx, SKUNotAvailableReason, instanceType.Name, getOfferingZone(offering), capacityType, skuNotAvailableTTL)
}
log.FromContext(ctx).Error(err, "")
return fmt.Errorf(
"the requested SKU is unavailable for instance type %s in zone %s with capacity type %s, for more details please visit: https://aka.ms/azureskunotavailable",
instanceType.Name,
zone,
capacityType)
}
if sdkerrors.ZonalAllocationFailureOccurred(err) {
log.FromContext(ctx).WithValues("zone", zone).Error(err, "")
p.unavailableOfferings.MarkUnavailable(ctx, ZonalAllocationFailureReason, instanceType.Name, zone, karpv1.CapacityTypeOnDemand)
p.unavailableOfferings.MarkUnavailable(ctx, ZonalAllocationFailureReason, instanceType.Name, zone, karpv1.CapacityTypeSpot)
return fmt.Errorf("unable to allocate resources in the selected zone (%s). (will try a different zone to fulfill your request)", zone)
}
if sdkerrors.RegionalQuotaHasBeenReached(err) {
log.FromContext(ctx).Error(err, "")
// InsufficientCapacityError is appropriate here because trying any other instance type will not help
return corecloudprovider.NewInsufficientCapacityError(
fmt.Errorf(
"regional %s vCPU quota limit for subscription has been reached. To scale beyond this limit, please review the quota increase process here: https://learn.microsoft.com/en-us/azure/quotas/regional-quota-requests",
capacityType))
}
return err
}