Skip to content

fix(quotas): CanLaunch's Spot path now tracks current Spot usage - #133

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/132-canlaunch-spot-usage-tracking
Aug 10, 2026
Merged

fix(quotas): CanLaunch's Spot path now tracks current Spot usage#133
scttfrdmn merged 1 commit into
mainfrom
fix/132-canlaunch-spot-usage-tracking

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

  • QuotaInfo gains SpotUsage, populated by splitting getCurrentUsage's DescribeInstances scan by InstanceLifecycle (spot vs on-demand) instead of summing both into one map.
  • CanLaunch's Spot branch now computes real headroom (quota - SpotUsage) instead of only confirming a request fits the full quota with zero usage signal — mirroring the on-demand branch's existing available := quota - usage pattern exactly.
  • Also fixes a second bug in the same code path that the issue didn't call out but the fix necessarily touches: on-demand Usage previously included running Spot instances' vCPUs too (the old getCurrentUsage summed every running/pending instance regardless of lifecycle), so on-demand headroom was understated by however many vCPUs were running as Spot. Splitting by lifecycle fixes both directions.

Real-world case (from the issue): an account with a 64-vCPU G/VT Spot quota already fully saturated by 8 running g7e.2xlarge instances got a false "fits" for 2 more shards, since 16 ≤ 64 (the full quota) in isolation — the actual RunInstances call then failed with MaxSpotInstanceCountExceeded with zero prior warning.

Fixes #132.

Test plan

  • New TestCanLaunch_SpotTracksCurrentUsage reproduces the exact calque scenario (quota fully saturated, partially used within headroom, partially used exceeding headroom, and the no-SpotUsage/nil-map fallback behaving as before)
  • Existing TestCanLaunch unchanged and passing
  • Confirmed the outside caller of .Usage (pkg/aws/obtainability.go's OnDemandQuotaHeadroom) is unaffected/correctly improved — it was already documented as on-demand-only and now actually gets on-demand-only data
  • go build ./..., go vet ./..., go test ./... (full repo) green
  • make check-fmt, golangci-lint run (0 issues), make check-docs (no drift), ./scripts/verify-pins.sh (15/15) all clean

QuotaInfo gains SpotUsage, populated by splitting getCurrentUsage's
DescribeInstances scan by InstanceLifecycle (spot vs on-demand)
instead of summing both lifecycles into one map. CanLaunch's Spot
branch now computes real headroom (quota - SpotUsage) instead of only
confirming a request fits the FULL quota with no usage signal, mirroring
the on-demand branch's existing pattern.

This also fixes a second, previously undiagnosed bug in the same code
path: on-demand Usage included running Spot instances' vCPUs too
(getCurrentUsage summed every running/pending instance regardless of
lifecycle), so on-demand headroom was understated by however many
vCPUs were running as Spot.

Real-world case: an account with a 64-vCPU G/VT Spot quota already
fully saturated by 8 running g7e.2xlarge instances got a false "fits"
for 2 more shards, since 16 <= 64 (the full quota) in isolation. The
actual RunInstances call then failed with MaxSpotInstanceCountExceeded
with zero prior warning.

Fixes #132.
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.22222% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/quotas/quotas.go 72.22% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 61cf91d into main Aug 10, 2026
6 checks passed
@scttfrdmn
scttfrdmn deleted the fix/132-canlaunch-spot-usage-tracking branch August 10, 2026 22:02
scttfrdmn added a commit that referenced this pull request Aug 10, 2026
Promotes Unreleased (Capabilities.VCPUs added in #134, CanLaunch Spot
usage tracking fixed in #133) to 0.49.0 and updates comparison links.
Also removes a stray unresolved merge-conflict marker left in the
Unreleased section by #134's merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quotas.CanLaunch: track current Spot usage, not just total quota (silent full-utilization false-positive)

1 participant