feat(api): check GPU budgets when a VM or a worker pool is written

GPU budgets are not pod resources, so ResourceQuota cannot enforce them.
Until the pool-wide admission gate is available, the API server needs
to check declared class reservations to avoid accepting applications
that exceed a tenant's budget. Reusing its inputs and pool arithmetic
keeps the eventual switch from changing admission decisions.

Tenant quota allocation must account for those reservations because
ResourceQuota usage cannot report them. Ordinary-resource accounting
must retain GPU-only descendants in the parent's pool, matching the
tenant chart and runtime controller. Unsupported keys in the GPU budget
domain must not create an unenforced promise when the chart omits them.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
Aleksei Sviridkin committed 2026-11-28 07:18:08 +03:00
1 parent 3a1bb156b9
commit 2d8af2bfe8
8 files changed
+857 -32

No files matched your search

+8
View File
@@ -118,6 +118,14 @@ The `resourceQuotas` parameter allows you to limit resources available to the te
- `secrets` - Maximum number of Secrets
- `persistentvolumeclaims` - Maximum number of PVCs
**GPU budgets** (checked when a VM or a worker pool is written, never rendered into the namespace ResourceQuota):
- `<class>.gpuclass.cozystack.io/devices` - GPUs of one GPUClass, each vGPU counting as one
- `gpuclass.cozystack.io/devices` - GPUs of every class together
A `VMInstance` reserves the `count` of each class entry and a `KubernetesNodes` pool reserves `count` times `maxReplicas`, stopped VMs included. A tenant with only GPU budgets gets no ResourceQuota and no default LimitRange.
GPU budgets are checked against the application's tenant pool, not recursively against every ancestor's GPU budget.
**Example:**
```yaml
resourceQuotas: