CreateFleet API-level failures (e.g. InternalError) bypass updateUnavailableOfferingsCache, so spot→on-demand fallback never engages

Author: eli-asteliaCreated Sep 22, 2026Updated Sep 22, 2026

Description

When CreateFleet fails at the API level (the SDK call returns a non-nil error), instance.go returns at line 401 — before updateUnavailableOfferingsCache() (line 574) is ever reached. That function only walks createFleetOutput.Errors, i.e. per-instance-type failures inside a successful API response.

The consequence: for an API-level failure, no offering is ever marked unavailable. A NodePool with capacity-type In [spot, on-demand] therefore keeps retrying the same (spot) capacity type and never falls back to on-demand, because fallback is driven entirely by the unavailable-offerings cache.

Relevant path in pkg/providers/instance/instance.go:

go
createFleetOutput, err := p.ec2Batcher.CreateFleet(ctx, createFleetInput)
p.subnetProvider.UpdateInflightIPs(...)
if err != nil {
    reason, message := awserrors.ToReasonMessage(err)
    if awserrors.IsLaunchTemplateNotFound(err) { ... }
    // line 401 — returns here; cache is never touched
    return ec2types.CreateFleetInstance{}, cloudprovider.NewCreateError(
        fmt.Errorf("creating fleet request, %w", err), reason,
        fmt.Sprintf("Error creating fleet request: %s", message))
}
// ...
// line 574 — only reached on a successful API call
p.updateUnavailableOfferingsCache(ctx, createFleetOutput.Errors, capacityType, ...)

InternalError is recognised by ToReasonMessage() (pkg/errors/errors.go:273-275) purely for the human-readable condition message, and is not in unfulfillableCapacityErrorCodes (errors.go:176-178) — but that set is irrelevant here, since the code that consults it never runs.

Observed Behavior

During a sustained EC2 spot-reclaim event in us-east-1 (2026-09-21 ~22:59 UTC onward), a production cluster lost spot capacity repeatedly — 10 SpotInterrupted events over ~35 minutes on a single arm64 NodePool.

Karpenter created replacement NodeClaims within seconds, but the CreateFleet calls failed:

NodeRegistrationHealthy  True -> False
Reason:  InternalError
Message: Error creating fleet request: An internal error has occurred

(×4 between 23:01:29 and 23:04:42 UTC.)

The NodePool is configured capacity-type In ["spot", "on-demand"], so on-demand fallback was expected. It never happened — every replacement attempt continued to request spot. ~15 pods across 4 namespaces stayed Pending for ~35 minutes until spot capacity recovered on its own.

FailedScheduling throughout showed the pods had nowhere to go, since the only nodes available carried taints from other NodePools:

0/10 nodes are available: 1 Insufficient memory, 3 Insufficient cpu,
7 node(s) had untolerated taint(s).

Note the NodePool applies its taint from .spec.template.spec.taints, so an on-demand node launched by this pool would have carried the same taint and been immediately schedulable. Fallback was the correct and sufficient remedy; it simply never engaged.

Expected Behavior

An API-level CreateFleet failure should not silently leave the capacity-type preference unchanged. Some options, in rough order of preference:

  1. Treat repeated API-level launch failures as a signal to try the next capacity type for a NodeClaim whose requirements permit it, rather than retrying the identical request until the 15-minute registration TTL expires.
  2. Distinguish retryable-but-capacity-neutral errors (InternalError, RequestLimitExceeded) from errors where retrying the same request is pointless, and back off the offering rather than just the NodeClaim.
  3. At minimum, document that spot→on-demand fallback covers capacity exhaustion only, and does not protect against CreateFleet API failures. The current behaviour is easy to misread as "on-demand fallback makes this pool immune to spot shortages."

Reproduction Steps

Hard to reproduce deterministically, as it requires EC2 to return InternalError from CreateFleet. It can be simulated by injecting an API-level error into the CreateFleet batcher and confirming that updateUnavailableOfferingsCache is not invoked and the next NodeClaim requests the same capacity type.

Relationship to existing issues

  • #6483 (InvalidFleetConfiguration does not trigger fallback) is the same symptom but a different mechanism: that error arrives inside createFleetOutput.Errors, so the cache path does run and only the IsUnfulfillableCapacity() membership test fails. Adding codes to unfulfillableCapacityErrorCodes would fix #6483 but would not fix this, because the cache path is skipped entirely.
  • #9175 (CreateFleet batcher amplifies rate-limit failures) touches the same err != nil branch, but is scoped to batching/throttle amplification rather than capacity-type fallback.
  • #8923 is arguably the inverse case for capacity reservations.

Versions

  • Karpenter: EKS Auto Mode (AWS-managed Karpenter) — exact build not introspectable. Line references above are to aws/karpenter-provider-aws@main as of 2026-09-22; the condition message and reason string match that code exactly, but a maintainer should confirm the managed build carries the same path.
  • Kubernetes: v1.36.2-eks-bca9cf6
  • OS: Bottlerocket (EKS Auto, Standard) 2026.9.14, arm64
  • Region: us-east-1

Source: aws/karpenter-provider-aws