Skip to content

aksd: DeployWizard: warn when deployment exceeds namespace resource quota#494

Merged
gambtho merged 2 commits intoAzure:mainfrom
gambtho:thgamble/paulfeedback2
Mar 25, 2026
Merged

aksd: DeployWizard: warn when deployment exceeds namespace resource quota#494
gambtho merged 2 commits intoAzure:mainfrom
gambtho:thgamble/paulfeedback2

Conversation

@gambtho
Copy link
Copy Markdown
Collaborator

@gambtho gambtho commented Mar 20, 2026

Summary

The deploy wizard's server-side dry-run validates the Deployment object but not the pods the ReplicaSet controller creates. When a namespace has a ResourceQuota, users could deploy successfully only to find pods stuck in FailedCreate with no prior warning.

  • Added checkResourceQuota() utility that fetches namespace ResourceQuotas and compares requested resources against remaining quota
  • Shows a non-blocking warning banner in the Deploy review step when resources would exceed quota
  • Added shared K8s resource quantity parsers (parseCpuToMillicores, parseMemoryToBytes, formatCpu, formatMemory)

Type of Change

  • New feature (non-breaking change which adds functionality)

Related Issues

Fixes #492 (quota warning portion; Map tab fix is in #493)

Changes Made

File Change
utils/shared/resourceUnits.ts New — K8s resource quantity parsers and formatters
utils/shared/resourceUnits.test.ts New — 15 unit tests
DeployWizard/utils/quotaCheck.ts New — fetches namespace quotas, compares against deployment resources
DeployWizard/utils/quotaCheck.test.ts New — 9 tests (fit, exceed, replicas, multi-container, RBAC fail-open, mixed docs)
DeployWizard/hooks/useDeployWizard.ts Added quotaWarnings state + useEffect that runs quota check on Deploy step entry
DeployWizard/components/DeployPure.tsx Renders quota warning banner (MUI warning.main color)
DeployWizard/components/Deploy.tsx Passes quotaWarnings through
DeployWizard/DeployWizard.tsx Passes quotaWarnings through

Design decisions

  • Warning, not a hard block — users can still deploy even when quota would be exceeded (the quota may change, or they may know what they're doing)
  • Fail-open — if the ResourceQuota fetch fails (e.g. RBAC), no warnings are shown rather than blocking deployment
  • Runs on step entry — quota check runs via useEffect when entering the Deploy review step, so warnings appear before the user clicks Deploy
  • Replica-aware — multiplies per-pod resources by spec.replicas (uses declared replicas, not HPA max, to keep it simple)
  • Checks 4 resource keysrequests.cpu, requests.memory, limits.cpu, limits.memory

Testing

  • Unit tests pass — 24 new tests all passing
  • TypeScript type check passes
  • ESLint passes (0 warnings)
  • Prettier formatting passes

Test Cases

  1. No quota in namespace — no warnings
  2. Resources fit within quota — no warnings
  3. Memory request exceeds remaining — warning with specific numbers
  4. CPU exceeds remaining — warning returned
  5. Replicas multiplied correctly (128Mi × 3 = 384Mi > 256Mi quota)
  6. Multiple containers summed correctly
  7. Non-Deployment resources (Service, ConfigMap) skipped
  8. Fetch failure (RBAC) — returns empty array (fail-open)
  9. Mixed docs — only Deployment checked

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@gambtho gambtho changed the title aksd: DeployWizard: warn when deployment exceeds namespace resource q… aksd: DeployWizard: warn when deployment exceeds namespace resource quota Mar 20, 2026
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch from e3c48ce to 40d902d Compare March 20, 2026 15:01
@gambtho gambtho marked this pull request as ready for review March 20, 2026 15:03
Copilot AI review requested due to automatic review settings March 20, 2026 15:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds advisory ResourceQuota awareness to the DeployWizard review step so users get warned (non-blocking) when their deployment’s pod resources would exceed remaining namespace quota.

Changes:

  • Introduces shared CPU/memory quantity parse/format helpers.
  • Adds checkResourceQuota() to fetch namespace quotas and compare against computed manifest totals.
  • Wires quota warnings through the DeployWizard hook and UI banner.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
plugins/aks-desktop/src/utils/shared/resourceUnits.ts Adds K8s resource quantity parsing/formatting helpers.
plugins/aks-desktop/src/utils/shared/resourceUnits.test.ts Unit tests for resource unit helpers.
plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts Computes totals from manifests and compares against ResourceQuota remaining.
plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.test.ts Unit tests for quota check behavior.
plugins/aks-desktop/src/components/DeployWizard/hooks/useDeployWizard.ts Runs quota check when entering Deploy step; plumbs warnings into state.
plugins/aks-desktop/src/components/DeployWizard/components/DeployPure.tsx Renders a warning banner in the Review & Deploy step.
plugins/aks-desktop/src/components/DeployWizard/components/Deploy.tsx Passes quotaWarnings to the pure component.
plugins/aks-desktop/src/components/DeployWizard/DeployWizard.tsx Passes quotaWarnings from wizard state into Deploy step.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/DeployWizard/hooks/useDeployWizard.ts Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts Outdated
Comment thread plugins/aks-desktop/src/utils/shared/resourceUnits.ts Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.test.ts Outdated
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch from 40d902d to c67cb37 Compare March 20, 2026 15:30
Copilot AI review requested due to automatic review settings March 20, 2026 15:35
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch from c67cb37 to c30ab40 Compare March 20, 2026 15:35
@gambtho gambtho marked this pull request as draft March 20, 2026 15:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/DeployWizard/hooks/useDeployWizard.ts Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts
Comment thread plugins/aks-desktop/src/utils/shared/resourceUnits.ts Outdated
Comment thread plugins/aks-desktop/src/utils/shared/resourceUnits.ts Outdated
Comment thread Localize/locales/en/plugin-translation.json Outdated
Comment thread Localize/locales/en/plugin-translation.json Outdated
@gambtho gambtho marked this pull request as ready for review March 20, 2026 21:51
Copilot AI review requested due to automatic review settings March 20, 2026 23:44
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch from 944ecf1 to 95c9db7 Compare March 20, 2026 23:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/utils/shared/resourceUnits.ts
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts Outdated
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch 2 times, most recently from 5e124df to 82cfdb4 Compare March 20, 2026 23:54
Copilot AI review requested due to automatic review settings March 20, 2026 23:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 28 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/components/DeployPure.tsx Outdated
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch from 82cfdb4 to 69f7922 Compare March 23, 2026 04:40
Copilot AI review requested due to automatic review settings March 24, 2026 13:47
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch from 69f7922 to f9ffc0c Compare March 24, 2026 13:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 29 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts
Comment thread plugins/aks-desktop/src/components/DeployWizard/components/DeployPure.tsx Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/hooks/useDeployWizard.ts Outdated
Comment thread plugins/aks-desktop/src/utils/shared/resourceUnits.ts
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch from f9ffc0c to a2547db Compare March 25, 2026 16:12
Copilot AI review requested due to automatic review settings March 25, 2026 16:12
sniok
sniok previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 30 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

headlamp:1

  • The PR description focuses on Deploy Wizard quota warnings, but this PR also updates the Headlamp submodule and includes very large localization churn across multiple locales. To keep review/audit scope clear, consider splitting the submodule + broad localization updates into a separate PR, or explicitly call them out in the PR description as intentional changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/utils/shared/resourceUnits.ts
Comment thread plugins/aks-desktop/locales/zh-Hans/translation.json Outdated
Comment thread plugins/aks-desktop/locales/id/translation.json Outdated
sniok
sniok previously approved these changes Mar 25, 2026
Copilot AI review requested due to automatic review settings March 25, 2026 16:39
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch from e6066ce to 30ea068 Compare March 25, 2026 16:39
@gambtho gambtho force-pushed the thgamble/paulfeedback2 branch from 30ea068 to 726171a Compare March 25, 2026 16:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts
Comment thread plugins/aks-desktop/src/utils/shared/resourceUnits.ts
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/quotaCheck.ts
@gambtho gambtho merged commit 207ae1b into Azure:main Mar 25, 2026
10 of 12 checks passed
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.

Deploy wizard: no warning when deployment exceeds namespace resource quota; Map tab fails for unscheduled pods

3 participants