Skip to content

RFE-9410: Add UI option to preserve managed clusters during cluster deletion from ACM#6325

Open
mihirlele wants to merge 5 commits into
stolostron:mainfrom
mihirlele:claude/feature/cluster-destroy-preserve-on-delete
Open

RFE-9410: Add UI option to preserve managed clusters during cluster deletion from ACM#6325
mihirlele wants to merge 5 commits into
stolostron:mainfrom
mihirlele:claude/feature/cluster-destroy-preserve-on-delete

Conversation

@mihirlele

@mihirlele mihirlele commented Jun 10, 2026

Copy link
Copy Markdown

📝 Summary

Ticket Summary (Title):
Add "Preserve cluster resources on delete" option to cluster destroy
dialog

Type of Change:

  • ✨ Feature

✅ Checklist

General

  • PR title follows the convention (e.g. ACM-12340 Fix bug with...)
  • Code builds and runs locally without errors
  • No console logs, commented-out code, or unnecessary files
  • All commits are meaningful and well-labeled
  • All new display strings are externalized for localization
    (English only)
  • (Nice to have) JSDoc comments added for new functions and
    interfaces

If Feature

  • UI/UX reviewed (if applicable)
  • All acceptance criteria met
  • Unit test coverage added or updated
  • Relevant documentation or comments included

🗒️ Notes for Reviewers

This feature adds a "Preserve cluster resources on delete"
checkbox to the destroy cluster confirmation dialog for
ACM-provisioned (Hive-backed) clusters. When checked, the UI patches
spec.preserveOnDelete: true on the ClusterDeployment before
issuing any delete calls. If the patch fails (e.g. RBAC error,
resource not found), the deletion is aborted entirely and an error
is shown in the dialog — no cluster resources are touched.

Key behaviour:

  • Checkbox is unchecked by default
  • Only shown for Hive/AI-provisioned clusters — not shown for
    Hypershift/Hosted clusters (no ClusterDeployment)
  • Patch abort = full deletion abort (safe by design)

Files changed:

File Change
BulkActionModal.tsx Added enablePreserveOnDelete prop +
checkbox UI
delete-cluster.ts Added preserveOnDelete param +
patch-then-delete logic
ClusterActionDropdown.tsx Passes `enablePreserveOnDelete:
true` to Hive destroy path only
cluster-deployment.ts Added preserveOnDelete?: boolean to
ClusterDeployment spec type
translation.json Added i18n key
delete-cluster.test.ts 3 new test cases: happy path, patch
failure aborts deletion, unchecked flow

To test the abort path, apply a ValidatingWebhookConfiguration
pointing at an unreachable URL with failurePolicy: Fail on
clusterdeployments UPDATE — see PR description for the exact
snippet.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added an optional “preserve on delete” checkbox to the cluster bulk Destroy action. When enabled, the deletion process retains the cluster’s preservation setting instead of fully removing it.
  • Behavior Changes
    • Deletion now supports a preservation flag and will stop if the preservation update step fails.
  • Tests
    • Added test coverage for preserve-on-delete scenarios (enabled, disabled, and failure cases).

mihirlele added 2 commits June 9, 2026 21:55
Adds a "Preserve cluster infrastructure on delete" checkbox to the
destroy cluster confirmation dialog for ACM-provisioned (Hive-backed)
clusters. When checked, the UI patches spec.preserveOnDelete=true on
the ClusterDeployment before proceeding with deletion. If the patch
fails the deletion is aborted and an error is surfaced to the user.

Checkbox is not shown for Hypershift/Hosted clusters.

Signed-off-by: mihirlele <mihirlele@users.noreply.github.com>
…urces on delete"

More accurate phrasing — the checkbox prevents deletion of provisioned
cluster resources (VMs, VPCs, instances, etc.) rather than generic
infrastructure. Also removes _specs/ and _plan/ from .gitignore.

Signed-off-by: mihirlele <mihirlele@users.noreply.github.com>
@openshift-ci

openshift-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mihirlele
Once this PR has been reviewed and has the lgtm label, please assign nitin-dhevar for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 69deee22-21d8-442c-beb0-a44e2b4295a5

📥 Commits

Reviewing files that changed from the base of the PR and between 913cfdf and a8733a7.

⛔ Files ignored due to path filters (1)
  • frontend/public/locales/en/translation.json is excluded by !frontend/public/locales/**
📒 Files selected for processing (3)
  • frontend/src/components/BulkActionModal.tsx
  • frontend/src/lib/delete-cluster.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/ClusterActionDropdown.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/ClusterActionDropdown.tsx
  • frontend/src/lib/delete-cluster.ts
  • frontend/src/components/BulkActionModal.tsx

📝 Walkthrough

Walkthrough

This PR adds cluster-deletion preservation support. ClusterDeployment spec gains an optional preserveOnDelete field. deleteCluster now accepts this flag, patches the resource before deletion when enabled, and refactors deletion logic into a runDelete() helper. BulkActionModal renders a conditional checkbox controlling this state, and ClusterActionDropdown integrates the UI with deletion logic. Tests cover success, failure, and disabled paths.

Changes

Preserve-on-delete cluster deletion

Layer / File(s) Summary
Data model contract
frontend/src/resources/cluster-deployment.ts
ClusterDeployment.spec interface extended with optional preserveOnDelete?: boolean field.
Delete logic implementation
frontend/src/lib/delete-cluster.ts
deleteCluster signature accepts optional preserveOnDelete flag. When true and cluster is neither Hypershift nor Hosted, function patches spec.preserveOnDelete: true before deletion. Deletion logic refactored into runDelete() helper preserving existing ignoreClusterDeploymentNotFound error handling. Returned abort cancels both patch and delete steps.
Delete logic test coverage
frontend/src/lib/delete-cluster.test.ts
Three test cases added: success path verifies patch request followed by deletion; failure path verifies deletion aborts when patch fails; false flag path verifies standard deletion flow skips patch step.
BulkActionModal preserve-on-delete UI
frontend/src/components/BulkActionModal.tsx
Props extended with enablePreserveOnDelete to gate UI. Component state initialized and reset to false on modal open. preserveOnDelete value passed to actionFn in both sequential and parallel execution paths. Conditional checkbox disables during operation progress.
ClusterActionDropdown integration
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/ClusterActionDropdown.tsx
Destroy action wired to enable preserve-on-delete via enablePreserveOnDelete: true on BulkActionModal. Checkbox state forwarded to deleteCluster as preserveOnDelete flag through options parameter.

Sequence Diagram

sequenceDiagram
  participant User
  participant ClusterActionDropdown
  participant BulkActionModal
  participant deleteCluster
  participant ClusterDeployment API
  User->>ClusterActionDropdown: Click Destroy
  ClusterActionDropdown->>BulkActionModal: Open with enablePreserveOnDelete
  BulkActionModal->>User: Show preserve-on-delete checkbox
  User->>BulkActionModal: Toggle checkbox, click confirm
  BulkActionModal->>ClusterActionDropdown: Call actionFn with preserveOnDelete
  ClusterActionDropdown->>deleteCluster: Call with preserveOnDelete flag
  deleteCluster->>ClusterDeployment API: PATCH spec.preserveOnDelete=true
  ClusterDeployment API-->>deleteCluster: Patch succeeds
  deleteCluster->>ClusterDeployment API: DELETE cluster resource
  ClusterDeployment API-->>deleteCluster: Deletion complete
  deleteCluster-->>ClusterActionDropdown: Success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main feature: adding a UI option to preserve managed clusters during deletion from ACM.
Description check ✅ Passed The description covers all required template sections with ticket details, change type, comprehensive checklist completion, and extensive notes for reviewers including implementation details and test guidance.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Satisfies docstring coverage threshold for the functions modified
in this PR.

Signed-off-by: mihirlele <mihirlele@users.noreply.github.com>
@mihirlele

Copy link
Copy Markdown
Author

/retest

Signed-off-by: mihirlele <mihirlele@users.noreply.github.com>
@mihirlele

Copy link
Copy Markdown
Author

/retest

@fxiang1 fxiang1 requested review from KevinFCormier and fxiang1 June 11, 2026 13:16
@KevinFCormier

Copy link
Copy Markdown
Contributor

/hold

@fxiang1

fxiang1 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@mihirlele This looks great! I just have a few questions I would like discuss.

  1. The "Preserve cluster resources on delete" checkbox doesn't appear when doing bulk destroy. I'm wondering if it makes sense to also add it there? Since destroy only applies to clusters selected with a ClusterDeployment I think we probably should.
bulk_destroy bulk_modal
  1. If the customer forgets about the cluster infrastructure on their cloud provider it will cost them a lot of money. I wonder if it also makes sense to just add an alert when they check the checkbox to remind the customer when they are doing this?

@mihirlele

mihirlele commented Jun 12, 2026

Copy link
Copy Markdown
Author

@fxiang1 thanks! yes I can add it for the bulk destroy too!

I am proposing another option for solving the second issue. How about we create a separate option for enabling preserve on delete/disabling preserve on delete (possibly in between detach and destroy). If preserve on delete is enabled, we can modify the destroy warning to also say that since preserve on delete is enabled, it will end up retaining the resources.

@fxiang1

fxiang1 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@fxiang1 thanks! yes I can add it for the bulk destroy too!

I am proposing another option for solving the second issue. How about we create a separate option for enabling preserve on delete/disabling preserve on delete (possibly in between detach and destroy). If preserve on delete is enabled, we can modify the destroy warning to also say that since preserve on delete is enabled, it will end up retaining the resources.

@mihirlele I'm just wondering how would this work? So we'll have another item in the table row action menu to enable/disable preserve on delete? Maybe you can do a mock up design? Thanks!

image

@mihirlele

Copy link
Copy Markdown
Author

@fxiang1 sure. I will share a short recording of how it would look like.

@mihirlele mihirlele closed this Jun 15, 2026
@mihirlele mihirlele deleted the claude/feature/cluster-destroy-preserve-on-delete branch June 15, 2026 10:26
@mihirlele mihirlele restored the claude/feature/cluster-destroy-preserve-on-delete branch June 15, 2026 12:17
@mihirlele mihirlele reopened this Jun 15, 2026
@sonarqubecloud

Copy link
Copy Markdown

@fxiang1 fxiang1 self-assigned this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants