From bc7c11c0eb609b083ebe8d8129d6d341fffc787c Mon Sep 17 00:00:00 2001 From: scttfrdmn <3011922+scttfrdmn@users.noreply.github.com> Date: Mon, 10 Aug 2026 13:51:57 -0700 Subject: [PATCH] feat(aws): add Capabilities.VCPUs (default vCPU count per instance type) Populated from DescribeInstanceTypes' VCpuInfo.DefaultVCpus. Lets a caller (spawn's sweep orchestrator, spawn#492) convert a per-family vCPU quota into an instance-count ceiling without re-implementing pkg/quotas.getVCPUCount's name-based size-suffix parsing, which its own fallback comment already documents as unreliable for non-linear sizes (p6-b200.48xlarge, metal sizes). --- CHANGELOG.md | 9 +++++++++ pkg/aws/client.go | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54c41ef..e34d23b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- **`Capabilities.VCPUs`** — the instance type's default vCPU count + (`DescribeInstanceTypes`' `VCpuInfo.DefaultVCpus`), so a caller can convert a + per-family vCPU quota (`pkg/quotas.QuotaInfo`) into an instance-count ceiling + without re-parsing the type's size suffix — the same name-based guessing + `pkg/quotas.getVCPUCount` already falls back to, which `obtainability.go`'s + own comment flags as unreliable for non-linear sizes (spawn#492). + ### Fixed - **`quotas.CanLaunch`'s Spot path now tracks current Spot usage** instead of only confirming a request fits the *full* Spot quota (#132). `QuotaInfo` @@ -19,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 instances got a false "fits" for 2 more, since 16 ≤ 64 (the full quota) in isolation — the actual launch then failed with `MaxSpotInstanceCountExceeded` with zero prior warning. +>>>>>>> 3117a40 (feat(aws): add Capabilities.VCPUs (default vCPU count per instance type)) ## [0.48.1] - 2026-08-07 diff --git a/pkg/aws/client.go b/pkg/aws/client.go index 7c600b5..a3f7ce3 100644 --- a/pkg/aws/client.go +++ b/pkg/aws/client.go @@ -594,6 +594,13 @@ type Capabilities struct { NestedVirtualization bool `json:"nested_virtualization"` // can run KVM/Hyper-V in-instance GPUs int32 `json:"gpus,omitempty"` BareMetal bool `json:"bare_metal"` + // VCPUs is the instance type's default vCPU count (EC2's VCpuInfo.DefaultVCpus). + // Lets a caller convert a per-family vCPU quota (pkg/quotas.QuotaInfo) into an + // instance count without re-parsing the type's size suffix — the same + // name-based guessing pkg/quotas.getVCPUCount uses as a last-resort fallback, + // which obtainability.go's own comment already flags as unreliable for + // non-linear sizes (p6-b200.48xlarge, metal sizes). spawn#492. + VCPUs int32 `json:"vcpus,omitempty"` } // GetCapabilities returns feature support for a single instance type in the @@ -643,6 +650,9 @@ func (c *Client) GetCapabilities(ctx context.Context, instanceType, region strin caps.Architectures = append(caps.Architectures, string(a)) } } + if it.VCpuInfo != nil && it.VCpuInfo.DefaultVCpus != nil { + caps.VCPUs = *it.VCpuInfo.DefaultVCpus + } return caps, nil }