frontend: Warn before deleting protected namespaces#6106
frontend: Warn before deleting protected namespaces#6106Anjali-Chauhan1 wants to merge 1 commit into
Conversation
Signed-off-by: Anjali-Chauhan1 <anjalichauhan1036@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Anjali-Chauhan1 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
mahesh-09-12
left a comment
There was a problem hiding this comment.
@Anjali-Chauhan1 took a look at the namespace safeguards and the changes around deletion behavior. The checks added here appear consistent with the expected restrictions, and the confirmation prompt is applied appropriately across the affected actions. I didn't spot any issues in the code paths modified by this update.
Summary
This PR adds a UI safeguard against accidentally deleting Kubernetes system namespaces. Headlamp previously showed Delete and Force Delete for every namespace — including
default,kube-system,kube-node-lease, andkube-public— so a user with a cluster-admin token could break a cluster with a single accidental click. These namespaces are now treated as protected: the delete dialog shows a warning and requires typing the namespace name to confirm.Related Issue
Fixes #6064
Changes
Namespace.PROTECTED_NAMESPACESand anisProtected()helper inlib/k8s/namespace.ts, matched against thekubernetes.io/metadata.namelabel (falling back to the object name).DeleteButtonto show a warning Alert and a type-the-name confirmation field, keeping the Delete button disabled until the name matches, for protected namespaces.DeleteMultipleButtonto flag any protected namespaces in a multi-select deletion.ConfirmDialogchange to support the disabled-confirm state.isProtected()and new Storybook stories + snapshots (ProtectedNamespace,NonProtectedNamespace).Steps to Test
kube-system). Observe the warning "This is a system namespace. Deleting it may break your cluster." and that Delete stays disabled until you type the namespace name.my-app). Observe the standard single-confirmation flow with no warning.Screenshots
Notes for the Reviewer
warning.mainon the Alert) rather than changing the shared theme, becausepalette.warning.lightis intentionally reused as a translucent background tint elsewhere (PluginSettingsDetails).