Skip to content

Fix: Retain namespace labels on managed namespace update#655

Open
tejhan wants to merge 1 commit into
Azure:mainfrom
tejhan:retainNamespaceLabelsOnUpdate
Open

Fix: Retain namespace labels on managed namespace update#655
tejhan wants to merge 1 commit into
Azure:mainfrom
tejhan:retainNamespaceLabelsOnUpdate

Conversation

@tejhan
Copy link
Copy Markdown
Collaborator

@tejhan tejhan commented May 12, 2026

Description

Currently, when updating a managed namespace via the Info tab, it silently removes the Headlamp & AKSD project labels. This renders Headlamp unable to recognize the project, leaving the user stuck with an infinite loading screen & a missing project on reload.

Separately, the az aks namespace command itself can often be slow, taking several minutes at worst, which even on a successful update, blocks the UI for the full duration.

Changes Made

  • Pass in the existing namespace labels into the updateManagedNamespace command so that they're preserved on update. This is needed due to the ARM PUT being a full replacement.
  • Wrapped the update handler with clusterAction so we can display the progress & operate async to relieve the user for long operation times vs. waiting on the one screen.
  • Pass subscriptionId into getManagedNamespace so that we have correct specificity for a multi-sub setup.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • CI/CD changes
  • Other: **___**

Testing

  • npm run plugin test

Manual Testing

  • Modify an item on the Info page, select update, then observe indicator & progress.

Test Cases

Describe the test cases that were run:

  1. Test case 1
  2. Test case 2
  3. Test case 3

Screenshots/Videos

If applicable, add screenshots or videos to demonstrate the changes.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • 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
  • Any dependent changes have been merged and published

Breaking Changes

If this is a breaking change, describe:

  • What breaks
  • How to migrate
  • Timeline for deprecation

Performance Impact

  • No performance impact
  • Performance improved
  • Performance degraded (explain why this is acceptable)

Documentation Updates

  • README.md updated
  • API documentation updated
  • Code comments updated
  • User guide updated
  • No documentation updates needed

Reviewer Notes

Any specific areas you'd like reviewers to focus on or questions you have.

Signed-off-by: tejhan-diallo <tejhan.diallo@gmail.com>
@tejhan tejhan self-assigned this May 12, 2026
Copilot AI review requested due to automatic review settings May 12, 2026 00:51
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

Fixes managed namespace updates so existing labels (including AKS Desktop + Headlamp project labels) are preserved, and moves the long-running update flow into a background clusterAction so the UI can show progress without blocking on the Info tab.

Changes:

  • Preserve existing managed-namespace labels during az aks namespace update by fetching current details and re-supplying --labels.
  • Run the InfoTab update via clusterAction and pass subscriptionId into the update call.
  • Update InfoTab hook tests to mock clusterAction and adapt assertions.

Reviewed changes

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

File Description
plugins/aks-desktop/src/utils/azure/az-namespaces.ts Fetches current managed namespace labels and re-supplies them to prevent label loss on update.
plugins/aks-desktop/src/components/InfoTab/hooks/useInfoTab.ts Wraps save/update in clusterAction, passes subscription, and switches update to --no-wait.
plugins/aks-desktop/src/components/InfoTab/hooks/useInfoTab.test.ts Adds clusterAction mock and adjusts save-failure expectations.

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

Comment on lines +235 to +236
} catch {
// Proceed without labels if the fetch fails.
memoryRequest: formData.memoryRequest,
memoryLimit: formData.memoryLimit,
subscriptionId: subscription,
noWait: true,
noWait: true,
});
setBaselineFormData(formData);
setError(null);
Comment on lines 326 to 340
await act(async () => {
await result.current.handleSave();
});

expect(mockUpdateManagedNamespace).toHaveBeenCalledWith(
expect.objectContaining({
clusterName: 'my-cluster',
resourceGroup: 'rg-prod',
namespaceName: 'my-project',
ingressPolicy: 'DenyAll',
})
);
// Baseline advances so hasChanges resets
expect(result.current.hasChanges).toBe(false);
});
{
startMessage: t('Updating namespace {{ name }}…', { name: projectId }),
cancelledMessage: t('Cancelled update of namespace {{ name }}.', { name: projectId }),
successMessage: t('Updated namespace {{ name }}.', { name: projectId }),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think you'll need to run npm run i18n:collect at the top-level to update these translations

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.

3 participants