Skip to content

Deploy: DeployWizard: Surface Gatekeeper/admission webhook errors during deploy#402

Merged
illume merged 2 commits into
Azure:mainfrom
gambtho:thgamble/262
Mar 13, 2026
Merged

Deploy: DeployWizard: Surface Gatekeeper/admission webhook errors during deploy#402
illume merged 2 commits into
Azure:mainfrom
gambtho:thgamble/262

Conversation

@gambtho
Copy link
Copy Markdown
Collaborator

@gambtho gambtho commented Mar 11, 2026

Summary

  • Add server-side dry-run validation (POST ?dryRun=All) before applying resources, catching admission webhook errors (e.g. Gatekeeper Deployment Safeguards) that Headlamp's apply() silently swallows via its 403 retry logic
  • Track per-resource success/failure during apply, showing users which resources succeeded and which failed with their error messages
  • Update error display to support multi-line messages with pre-wrap formatting

Fixes #262

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Changes Made

  • dryRunApply.ts (new) — Utility that sends POST ?dryRun=All via clusterRequest to trigger server-side validation including admission webhooks without persisting resources. Includes Kind-to-plural resource name mapping and API path construction for core (/api/v1) and extended (/apis/<group>/<version>) API groups, with cluster-scoped resource handling.
  • DeployWizard.tsxhandleDeploy now runs in two phases: (1) dry-run all resources first, collecting any validation errors and stopping if any fail; (2) apply with per-resource try-catch, reporting partial success/failure counts.
  • Deploy.tsx — Error message box uses <Typography component="pre"> with whiteSpace: 'pre-wrap' to render multi-line Gatekeeper errors and per-resource error lists.
  • dryRunApply.test.ts (new) — 10 unit tests for getResourcePlural, buildApiPath, and dryRunApply (success, 403/Gatekeeper error, cluster parameter).
  • DeployWizard.test.tsx (new) — 4 integration tests: dry-run failure blocks apply, dry-run success proceeds, partial apply failure shows per-resource status, multiple dry-run errors displayed.

Testing

  • Unit tests pass (npx vitest run src/components/DeployWizard/ — 14/14 passing)
  • TypeScript type check passes
  • ESLint passes
  • Prettier formatting passes
  • Plugin build passes
  • Manual testing on AKS Automatic cluster with Deployment Safeguards

Test Cases

  1. Deploy a manifest with image: nginx:latest to an AKS Automatic cluster with Deployment Safeguards — should show Gatekeeper denial message before any resources are created
  2. Deploy a valid manifest — dry-run passes, resources applied successfully
  3. Deploy multiple resources where one violates policy — dry-run catches it, no resources created, all errors shown
  4. Deploy multiple valid resources where one fails during actual apply — shows partial success count and per-resource error

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

Performance Impact

  • No performance impact (dry-run adds one lightweight API call per resource before apply)

Copilot AI review requested due to automatic review settings March 11, 2026 04:23
@gambtho gambtho changed the title plugins/aksdesktop: surface Gatekeeper/admission webhook errors durin… Surface Gatekeeper/admission webhook errors during deploy Mar 11, 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

Adds server-side dry-run validation to the AKS Desktop Deploy Wizard so admission webhook (e.g., Gatekeeper) failures are surfaced to users instead of being masked by Headlamp’s apply/retry behavior, and improves feedback for partial deploy failures.

Changes:

  • Introduces dryRunApply() and runs it before apply() to surface admission webhook errors early.
  • Tracks per-resource apply failures to report partial deployment results instead of failing silently.
  • Improves deploy message rendering (preserves multiline formatting) and adds unit/UI tests for the new behavior.

Reviewed changes

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

Show a summary per file
File Description
plugins/aks-desktop/src/components/DeployWizard/utils/dryRunApply.ts Adds a dry-run request helper that builds k8s API paths and POSTs with dryRun=All.
plugins/aks-desktop/src/components/DeployWizard/utils/dryRunApply.test.ts Adds unit tests for path-building and dry-run request behavior.
plugins/aks-desktop/src/components/DeployWizard/components/Deploy.tsx Renders deploy output as preformatted text to preserve multi-line errors.
plugins/aks-desktop/src/components/DeployWizard/DeployWizard.tsx Adds dry-run validation phase + per-resource apply error aggregation/messages.
plugins/aks-desktop/src/components/DeployWizard/DeployWizard.test.tsx Adds UI tests covering dry-run failures, successful deploys, and partial apply failures.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/dryRunApply.ts Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/dryRunApply.ts Outdated
Copilot AI review requested due to automatic review settings March 11, 2026 05:18
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 5 out of 5 changed files in this pull request and generated 3 comments.


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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/dryRunApply.ts Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/DeployWizard.tsx Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/dryRunApply.ts Outdated
Copilot AI review requested due to automatic review settings March 11, 2026 05:34
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 5 out of 5 changed files in this pull request and generated 2 comments.


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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread plugins/aks-desktop/src/components/DeployWizard/DeployWizard.tsx Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/dryRunApply.ts Outdated
@illume illume added the p0 Highest priority label Mar 11, 2026
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

I'd like the other DeployWizard PR merged first

@illume illume changed the title Surface Gatekeeper/admission webhook errors during deploy Deploy: DeployWizard: Surface Gatekeeper/admission webhook errors during deploy Mar 11, 2026
@gambtho
Copy link
Copy Markdown
Collaborator Author

gambtho commented Mar 11, 2026

I'd like the other DeployWizard PR merged first

agreed -- i'll rebase after that merges

sniok
sniok previously approved these changes Mar 12, 2026
Copy link
Copy Markdown
Collaborator

@sniok sniok left a comment

Choose a reason for hiding this comment

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

lgtm

@illume illume added the bug Something isn't working label Mar 12, 2026
…g deploy

Add server-side dry-run validation (POST ?dryRun=All) before applying
resources, catching admission webhook errors (e.g. Gatekeeper Deployment
Safeguards) that Headlamp's apply() silently swallows via its 403 retry
logic. Track per-resource success/failure during apply, showing users
which resources succeeded and which failed with their error messages.
Update error display to support multi-line messages with pre-wrap
formatting.

Fixes Azure#262
Copilot AI review requested due to automatic review settings March 12, 2026 21:10
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 25 out of 25 changed files in this pull request and generated 1 comment.


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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread plugins/aks-desktop/src/components/DeployWizard/hooks/useDeployWizard.ts Outdated
illume
illume previously approved these changes Mar 12, 2026
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

🎉 thanks!

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 25 out of 25 changed files in this pull request and generated 3 comments.


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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread plugins/aks-desktop/src/components/DeployWizard/utils/dryRunApply.ts Outdated
Comment thread plugins/aks-desktop/src/components/DeployWizard/hooks/useDeployWizard.ts Outdated
@illume
Copy link
Copy Markdown
Collaborator

illume commented Mar 12, 2026

@gambtho
Maybe these extra copilot comments are worth considering?

Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

🎉 thanks!

@illume illume merged commit 6693d4a into Azure:main Mar 13, 2026
8 checks passed
@illume illume mentioned this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p0 Highest priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Silent errors when attempting to deploy applications that violate Gatekeeper constraints

4 participants