Skip to content

ROSAENG-61732 | feat: Add create-time delete protection to rosa create cluster#3367

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
michaelryanmcneill:ROSAENG-61732
Jul 15, 2026
Merged

ROSAENG-61732 | feat: Add create-time delete protection to rosa create cluster#3367
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
michaelryanmcneill:ROSAENG-61732

Conversation

@michaelryanmcneill

@michaelryanmcneill michaelryanmcneill commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

PR Summary

Add create-time --enable-delete-protection to rosa create cluster, fast-fail rosa delete cluster when protection is active (with an actionable disable command), clearer create/edit flag help text, and e2e coverage mirroring the existing edit-path tests.

Detailed Description of the Issue

ROSA supports OCM delete protection via the /delete_protection sub-resource. The CLI already exposes day-2 toggling through rosa edit cluster --enable-delete-protection, but:

  1. Create had no equivalent flag — operators had to run a separate edit after the cluster existed.
  2. Delete relied on the OCM DELETE API to reject protected clusters — no local fast-fail with a clear remediation path.
  3. Flag help text said "Toggle..." without documenting that --enable-delete-protection=false disables protection on edit.

Delete protection is not part of the cluster POST body; the correct create pattern is POST cluster → PATCH delete_protection.

Related Issues and PRs

Type of Change

  • feat - adds a new user-facing capability.
  • fix - resolves an incorrect behavior or bug.
  • docs - updates documentation only.
  • style - formatting or naming changes with no logic impact.
  • refactor - code restructuring with no behavior change.
  • test - adds or updates tests only.
  • chore - maintenance work (tooling, housekeeping, non-product code).
  • build - changes build system, packaging, or dependencies for build output.
  • ci - changes CI pipelines, jobs, or automation workflows.
  • perf - improves performance without changing intended behavior.

Previous Behavior

  • rosa create cluster had no delete protection flag.
  • Delete protection could only be enabled after create via rosa edit cluster --enable-delete-protection.
  • rosa delete cluster relied on the OCM DELETE API error when protection was enabled (no local check).
  • Flag help did not explain how to disable protection.
  • E2E coverage existed only for edit-path delete protection (cases 73161 / 74656).

Behavior After This Change

Create (rosa create cluster)

  • --enable-delete-protection enables OCM delete protection immediately after successful cluster creation (Classic and HCP).
  • Interactive mode prompts "Enable cluster deletion protection" (default false).
  • Post-create PATCH uses existing UpdateClusterDeletionProtection; create fails if PATCH fails, with cluster ID in the error (cluster already exists).
  • Flag is not added to ocm.Spec — sub-resource only.
  • buildCommand() replay includes --enable-delete-protection when set (including interactive choice synced back to args).
  • Help: "Enable cluster deletion protection against accidental deletion after the cluster is created."

Edit (rosa edit cluster)

  • Same boolean flag as before; disable with --enable-delete-protection=false (no new flag).
  • Help: "Enable or disable cluster deletion protection against accidental deletion. Use '--enable-delete-protection=false' to disable."

Delete (rosa delete cluster)

  • Fast-fail before confirm — fetch cluster and check GetClusterDeletionProtection before prompting confirm.Confirm("delete cluster …"), so users are not asked to confirm a delete that cannot proceed.
  • Error includes remediation:

    Delete protection is active on cluster '<name-or-id>'. It cannot be deleted until delete protection is disabled. To disable delete protection, run 'rosa edit cluster -c <name-or-id> --enable-delete-protection=false'.

Library

  • GetClusterDeletionProtection(clusterID) added in pkg/ocm/clusters.go for live sub-resource GET.

How to Test (Step-by-Step)

Preconditions

  • ROSA CLI built from this branch (make rosa).
  • OCM credentials configured for manual checks; unit tests do not need live credentials.

Test Steps

  1. Confirm flag and help text:
    rosa create cluster --help | grep -A1 enable-delete-protection
    rosa edit cluster --help | grep -A2 enable-delete-protection
  2. Run unit tests:
    go test ./cmd/create/cluster/ ./cmd/edit/cluster/ ./cmd/dlt/cluster/ -count=1
    go test ./pkg/ocm/ -ginkgo.focus='DeleteProtection' -count=1
  3. (Optional, manual) Create with --enable-delete-protection, describe, attempt delete (expect fast-fail with disable command), then disable and delete.
  4. E2E (when running Day1 / Day1Negative / Day1Post suites):
    • Create + protect + blocked delete: [id:73162]
    • Invalid create flag values: [id:74657]
    • Create help exposes flag: [id:73163]

Expected Results

  1. Create help documents enable-at-create; edit help documents =false to disable.
  2. Delete with protection enabled fails locally with the remediation message (no DELETE call to OCM).
  3. Unit tests pass, including delete-protection enabled/disabled cases in cmd/dlt/cluster.
  4. Manual create → describe shows protection enabled; delete is blocked until rosa edit cluster -c … --enable-delete-protection=false.

Proof of the Fix

  • Screenshots: N/A

  • Videos: N/A

  • Logs/CLI output:

    go test ./cmd/create/cluster/ ./pkg/ocm/ -count=1
    make lint
    make test
    > ./rosa create cluster --cluster-name protect-hcp --create-admin-user --role-arn arn:aws:iam::xxx:role/ManagedOpenShift-HCP-ROSA-Installer-Role --support-role-arn arn:aws:iam::xxx:role/ManagedOpenShift-HCP-ROSA-Support-Role --worker-iam-role arn:aws:iam::xxx:role/ManagedOpenShift-HCP-ROSA-Worker-Role --operator-roles-prefix protect-hcp --oidc-config-id xxx --region us-east-1 --version 4.22.3 --channel stable-4.22 --ec2-metadata-http-tokens required --replicas 3 --compute-machine-type m7i.xlarge --machine-cidr 10.0.0.0/16 --service-cidr 172.30.0.0/16 --pod-cidr 10.128.0.0/14 --host-prefix 23 --subnet-ids subnet-xxx,subnet-xxx --enable-delete-protection --hosted-cp --billing-account xxx
    Name:                       protect-hcp
    ......
    Delete Protection:          Enabled
    Created:                    Jul 13 2026 17:20:44 UTC
    
    >./rosa describe cluster -c protect-hcp
    Name:                       protect-hcp
    ...
    Delete Protection:          Enabled
    Created:                    Jul 13 2026 17:20:44 UTC
    
    > ./rosa delete cluster -c protect-hcp
    E: Delete protection is active on cluster 'protect-hcp'. It cannot be deleted until delete protection is disabled. To disable delete protection, run 'rosa edit cluster -c protect-hcp --enable-delete-protection=false'.
    
  • Other artifacts: cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml

Breaking Changes

  • No breaking changes
  • Yes, this PR introduces a breaking change (describe impact and migration plan below)

Breaking Change Details / Migration Plan

N/A — new optional create flag (default off); delete now fails earlier with a clearer message when protection is already active (same outcome as API rejection). Help text wording only for create/edit flags.

Developer Verification Checklist

  • Commit subject/title follows [JIRA-TICKET] | [TYPE]: <MESSAGE>.
  • PR description clearly explains both what changed and why.
  • Relevant Jira/GitHub issues and related PRs are linked.
  • make install-hooks has been run in this clone.
  • Tests were added/updated where appropriate.
  • I manually tested the change.
  • make test passes.
  • make lint passes.
  • make rosa passes.
  • Documentation or repo-local agent guidance was added/updated where appropriate.
  • Any risk, limitation, or follow-up work is documented.

Additional Notes

After discussion, we've decided to fail in the event that the PATCH to the cluster deletion does not succeed. This means that the user won't see the "cluster created" message or STS cleanup commands if the error fires. This is intended to prevent automation silent failures which could result in a cluster being created without the intended deletion protection.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added --enable-delete-protection to rosa create cluster, including interactive prompting and --run again support; when enabled, delete protection is applied after creation (non-dry-run).
  • Bug Fixes
    • rosa delete cluster now checks delete protection upfront and exits early with clearer guidance when it’s enabled.
  • Documentation
    • Expanded --enable-delete-protection help text and aligned prompt wording to “delete protection.”
  • Tests
    • Expanded unit and end-to-end coverage for help output, invalid argument validation, and enabled/disabled delete-protection deletion behavior.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 13, 2026
@openshift-ci

openshift-ci Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 56df65b9-7014-4ce8-baf4-1689ba2bbb2b

📥 Commits

Reviewing files that changed from the base of the PR and between 1cc42ad and 918911c.

📒 Files selected for processing (10)
  • cmd/create/cluster/cmd.go
  • cmd/create/cluster/cmd_test.go
  • cmd/dlt/cluster/cmd.go
  • cmd/dlt/cluster/cmd_test.go
  • cmd/edit/cluster/cmd.go
  • cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml
  • pkg/ocm/clusters.go
  • pkg/ocm/delete_protection_test.go
  • tests/e2e/test_rosacli_cluster.go
  • tests/e2e/test_rosacli_cluster_post.go
🚧 Files skipped from review as they are similar to previous changes (8)
  • cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml
  • cmd/create/cluster/cmd_test.go
  • cmd/dlt/cluster/cmd_test.go
  • cmd/dlt/cluster/cmd.go
  • tests/e2e/test_rosacli_cluster_post.go
  • cmd/create/cluster/cmd.go
  • cmd/edit/cluster/cmd.go
  • tests/e2e/test_rosacli_cluster.go

📝 Walkthrough

Walkthrough

Cluster creation supports --enable-delete-protection through flags and interactive prompts, applies protection after creation, and includes it in rerun commands. The OCM update method is renamed, and cluster editing uses the new name. Cluster deletion checks protection before proceeding. Tests cover API responses, command arguments, help output, invalid values, and HCP and Classic lifecycle behavior.

Possibly related PRs

Suggested reviewers: jerichokeyne, davidleerh

🚥 Pre-merge checks | ✅ 13 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Ipv6 And Disconnected Network Test Compatibility ⚠️ Warning The new HCP/Classic create/delete-protection e2e suite provisions real clusters and uses GenerateClusterCreateFlags(), which hardcodes IPv4 CIDRs. Make the create-profile helper family-aware or skip the suite in disconnected/IPv6 jobs; verify the HCP path without hardcoded IPv4 CIDRs.
✅ Passed checks (13 passed)
Check name Status Explanation
Title check ✅ Passed Matches the main change and follows the required Jira/type format.
Description check ✅ Passed Includes all required sections and explains the problem, changes, testing, and related issues.
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.
Stable And Deterministic Test Names ✅ Passed All added/changed Ginkgo titles are fixed string literals; no titles embed generated names, timestamps, UUIDs, or other run-time values.
Test Structure And Quality ✅ Passed The added Ginkgo tests use shared setup/teardown, explicit uninstall wait timeouts, and match existing repo patterns; no leaks or indefinite waits found.
Microshift Test Compatibility ✅ Passed The new e2e cases only exercise ROSA CLI/OCM flows and help text; they don’t reference MicroShift-unsupported OpenShift APIs or guarded features.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The new e2e tests only check CLI help and cluster delete-protection behavior; they don't inspect, count, or require multiple nodes or HA topology.
Topology-Aware Scheduling Compatibility ✅ Passed PR only changes CLI/OCM/test files; no manifests, controllers, or scheduling constraints/topology assumptions were added.
Ote Binary Stdout Contract ✅ Passed New code is confined to command handlers and test bodies; no stdout writes were added in init/TestMain/BeforeSuite/RunSpecs setup.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret/token comparisons were added in touched files; changes are delete-protection only.
Container-Privileges ✅ Passed Touched files are CLI Go/tests and a schema YAML; no container/K8s manifests or privilege fields (privileged, hostPID/Network/IPC, allowPrivilegeEscalation) were added.
No-Sensitive-Data-In-Logs ✅ Passed New logs only mention delete-protection state and cluster IDs; no passwords, tokens, API keys, PII, or hostnames are logged in the patch.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
pkg/ocm/clusters.go (1)

790-803: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a doc comment and align the parameter name with the sibling method.

GetClusterDeletionProtection is a new exported method without a doc comment, and its parameter is named clusterID while the adjacent UpdateClusterDeletionProtection uses clusterId for the same concept.

📝 Proposed fix
+// GetClusterDeletionProtection retrieves the delete-protection state for the given cluster.
-func (c *Client) GetClusterDeletionProtection(clusterID string) (bool, error) {
+func (c *Client) GetClusterDeletionProtection(clusterId string) (bool, error) {
 	response, err := c.ocm.ClustersMgmt().V1().Clusters().
-		Cluster(clusterID).
+		Cluster(clusterId).
 		DeleteProtection().
 		Get().
 		Send()
As per coding guidelines, "Use exported symbol doc comments when new public types or functions are introduced" and "Keep variable names explicit and consistent with nearby code."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/ocm/clusters.go` around lines 790 - 803, Add a Go doc comment for the
exported Client.GetClusterDeletionProtection method, and rename its clusterID
parameter to clusterId to match UpdateClusterDeletionProtection and nearby code
while preserving the existing behavior.

Source: Coding guidelines

pkg/ocm/delete_protection_test.go (1)

52-63: 🎯 Functional Correctness | 🔵 Trivial

Consider covering the error and empty-body branches too.

Only the "enabled" happy path is tested. GetClusterDeletionProtection also has an API-error branch and a nil-body branch (pkg/ocm/clusters.go lines 796-801) that aren't exercised here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/ocm/delete_protection_test.go` around lines 52 - 63, Extend the
GetClusterDeletionProtection tests in delete_protection_test.go to cover both an
API error response and a successful response with an empty or nil body. Assert
that the API-error case returns an error and that the nil-body branch produces
the expected result, reusing the existing apiServer and response helpers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/create/cluster/cmd.go`:
- Around line 3685-3700: In the enableDeleteProtection flow, replace the
os.Exit(1) after UpdateClusterDeletionProtection fails with a warning via
r.Reporter, then continue execution so cluster description and STS/OIDC
follow-up instructions are still produced. Keep the existing fatal handling for
delete-protection builder errors unchanged.

In `@pkg/ocm/delete_protection_test.go`:
- Line 60: Extend the tests around GetClusterDeletionProtection to cover both
response.Error() failures and responses where response.Body() is nil. Assert the
expected error behavior for each case while preserving the existing
successful-path coverage.

---

Nitpick comments:
In `@pkg/ocm/clusters.go`:
- Around line 790-803: Add a Go doc comment for the exported
Client.GetClusterDeletionProtection method, and rename its clusterID parameter
to clusterId to match UpdateClusterDeletionProtection and nearby code while
preserving the existing behavior.

In `@pkg/ocm/delete_protection_test.go`:
- Around line 52-63: Extend the GetClusterDeletionProtection tests in
delete_protection_test.go to cover both an API error response and a successful
response with an empty or nil body. Assert that the API-error case returns an
error and that the nil-body branch produces the expected result, reusing the
existing apiServer and response helpers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 801dfa40-3eb1-4c1a-8579-891811bda633

📥 Commits

Reviewing files that changed from the base of the PR and between b289754 and 02324ea.

📒 Files selected for processing (5)
  • cmd/create/cluster/cmd.go
  • cmd/create/cluster/cmd_test.go
  • cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml
  • pkg/ocm/clusters.go
  • pkg/ocm/delete_protection_test.go

Comment thread cmd/create/cluster/cmd.go
Comment thread pkg/ocm/delete_protection_test.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
cmd/create/cluster/cmd.go (1)

3685-3699: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Build-error branch still aborts the whole post-creation flow; only the update-error branch was fixed.

The UpdateClusterDeletionProtection failure now correctly warns and continues (matching the earlier review feedback), but the Build() failure branch above it (lines 3687-3690) still calls os.Exit(1) after the cluster has already been created — this loses the cluster-describe output and STS/OIDC follow-up instructions, the exact issue previously raised for this block. Since Enabled(true).Build() has no required fields, this path is unlikely to fail, but for consistency it should warn instead of exit too.

🔧 Proposed fix
 	if enableDeleteProtection {
 		deleteProtection, err := v1.NewDeleteProtection().Enabled(true).Build()
 		if err != nil {
-			r.Reporter.Errorf("Failed to build delete protection: %v", err)
-			os.Exit(1)
-		}
-		if err := r.OCMClient.UpdateClusterDeletionProtection(cluster.ID(), deleteProtection); err != nil {
-			r.Reporter.Warnf(
-				"Cluster '%s' was created but delete protection could not be enabled: %v",
-				cluster.ID(),
-				err,
-			)
+			r.Reporter.Warnf("Cluster '%s' was created but delete protection could not be enabled: %v. "+
+				"You can enable it later with 'rosa edit cluster'.", cluster.ID(), err)
+		} else if err := r.OCMClient.UpdateClusterDeletionProtection(cluster.ID(), deleteProtection); err != nil {
+			r.Reporter.Warnf(
+				"Cluster '%s' was created but delete protection could not be enabled: %v",
+				cluster.ID(),
+				err,
+			)
 		}
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/create/cluster/cmd.go` around lines 3685 - 3699, Update the
`v1.NewDeleteProtection().Enabled(true).Build()` error branch in the
`enableDeleteProtection` flow to report a warning and continue instead of
calling `os.Exit(1)`. Preserve the existing warning-and-continue behavior for
`UpdateClusterDeletionProtection`, allowing the post-creation cluster
description and follow-up instructions to run.
🧹 Nitpick comments (1)
cmd/dlt/cluster/cmd_test.go (1)

151-179: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for GetClusterDeletionProtection returning an error.

Only the enabled/disabled branches are tested; the branch where the OCM call itself fails (line 141 in cmd.go) is untested, even though it now short-circuits cluster deletion.

As per coding guidelines, "Add focused automated tests when behavior changes in a way that could regress."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/dlt/cluster/cmd_test.go` around lines 151 - 179, Add a focused test in
the ensureDeleteProtectionDisabled context covering GetClusterDeletionProtection
returning an error from the API call. Configure the mock server to return a
failure, invoke ensureDeleteProtectionDisabled, and assert that the error is
propagated and cluster deletion is short-circuited without treating protection
as enabled or disabled.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/ocm/delete_protection_test.go`:
- Around line 74-82: The test currently covers an empty JSON object rather than
a nil response body. Update the test around GetClusterDeletionProtection to
construct or return a response with Body() equal to nil, then assert the call
returns the “delete protection response body is empty” error and the expected
disabled value.

In `@tests/e2e/test_rosacli_cluster.go`:
- Around line 463-464: Update both ContainSubstring assertions in the relevant
ROSA CLI test to use the exact lowercase text “delete protection is active,”
including the assertion that currently checks the capitalized variant; leave the
--enable-delete-protection=false assertion unchanged.

---

Duplicate comments:
In `@cmd/create/cluster/cmd.go`:
- Around line 3685-3699: Update the
`v1.NewDeleteProtection().Enabled(true).Build()` error branch in the
`enableDeleteProtection` flow to report a warning and continue instead of
calling `os.Exit(1)`. Preserve the existing warning-and-continue behavior for
`UpdateClusterDeletionProtection`, allowing the post-creation cluster
description and follow-up instructions to run.

---

Nitpick comments:
In `@cmd/dlt/cluster/cmd_test.go`:
- Around line 151-179: Add a focused test in the ensureDeleteProtectionDisabled
context covering GetClusterDeletionProtection returning an error from the API
call. Configure the mock server to return a failure, invoke
ensureDeleteProtectionDisabled, and assert that the error is propagated and
cluster deletion is short-circuited without treating protection as enabled or
disabled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: b417cb43-0e17-4b61-a20c-1b7366bedb3b

📥 Commits

Reviewing files that changed from the base of the PR and between 02324ea and 8d6abea.

📒 Files selected for processing (10)
  • cmd/create/cluster/cmd.go
  • cmd/create/cluster/cmd_test.go
  • cmd/dlt/cluster/cmd.go
  • cmd/dlt/cluster/cmd_test.go
  • cmd/edit/cluster/cmd.go
  • cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml
  • pkg/ocm/clusters.go
  • pkg/ocm/delete_protection_test.go
  • tests/e2e/test_rosacli_cluster.go
  • tests/e2e/test_rosacli_cluster_post.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml
  • cmd/create/cluster/cmd_test.go
  • pkg/ocm/clusters.go

Comment thread pkg/ocm/delete_protection_test.go Outdated
Comment thread tests/e2e/test_rosacli_cluster.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cmd/create/cluster/cmd.go (1)

3686-3695: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid shadowing err in the post-creation branch.

Line 3686 shadows the outer err, and Line 3691 shadows it again. Use distinct names such as buildErr and updateErr to follow the Go guidance and keep the two failure paths unambiguous.

Proposed fix
-		deleteProtection, err := v1.NewDeleteProtection().Enabled(true).Build()
-		if err != nil {
-			r.Reporter.Errorf("Failed to build delete protection: %v", err)
+		deleteProtection, buildErr := v1.NewDeleteProtection().Enabled(true).Build()
+		if buildErr != nil {
+			r.Reporter.Errorf("Failed to build delete protection: %v", buildErr)
 			os.Exit(1)
 		}
-		if err := r.OCMClient.UpdateClusterDeletionProtection(cluster.ID(), deleteProtection); err != nil {
+		if updateErr := r.OCMClient.UpdateClusterDeletionProtection(cluster.ID(), deleteProtection); updateErr != nil {
 			r.Reporter.Warnf(
 				"Cluster '%s' was created but delete protection could not be enabled: %v",
 				cluster.ID(),
-				err,
+				updateErr,
 			)
 		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/create/cluster/cmd.go` around lines 3686 - 3695, Rename the inner error
variables in the post-creation delete-protection flow to avoid shadowing the
outer err: use distinct names such as buildErr for
NewDeleteProtection().Enabled(true).Build() and updateErr for
UpdateClusterDeletionProtection. Update each corresponding error check and log
reference while preserving the existing failure behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cmd/create/cluster/cmd.go`:
- Around line 3686-3695: Rename the inner error variables in the post-creation
delete-protection flow to avoid shadowing the outer err: use distinct names such
as buildErr for NewDeleteProtection().Enabled(true).Build() and updateErr for
UpdateClusterDeletionProtection. Update each corresponding error check and log
reference while preserving the existing failure behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: cf58033b-9a1c-46e6-9ade-1d6f7ba6a271

📥 Commits

Reviewing files that changed from the base of the PR and between 8d6abea and 8b03f1a.

📒 Files selected for processing (10)
  • cmd/create/cluster/cmd.go
  • cmd/create/cluster/cmd_test.go
  • cmd/dlt/cluster/cmd.go
  • cmd/dlt/cluster/cmd_test.go
  • cmd/edit/cluster/cmd.go
  • cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml
  • pkg/ocm/clusters.go
  • pkg/ocm/delete_protection_test.go
  • tests/e2e/test_rosacli_cluster.go
  • tests/e2e/test_rosacli_cluster_post.go
🚧 Files skipped from review as they are similar to previous changes (8)
  • cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml
  • cmd/dlt/cluster/cmd_test.go
  • cmd/edit/cluster/cmd.go
  • cmd/create/cluster/cmd_test.go
  • pkg/ocm/delete_protection_test.go
  • tests/e2e/test_rosacli_cluster_post.go
  • cmd/dlt/cluster/cmd.go
  • tests/e2e/test_rosacli_cluster.go

@michaelryanmcneill
michaelryanmcneill marked this pull request as ready for review July 14, 2026 03:49
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/test_rosacli_cluster.go`:
- Around line 463-464: Update the delete-protection error assertions in the
current test and the Day1 delete-protection test to match the CLI message’s
punctuation, placing the comma after the cluster ID rather than directly after
“active”. Keep the existing --enable-delete-protection=false assertion
unchanged.
- Around line 1919-1925: Update both delete-protection assertions in
tests/e2e/test_rosacli_cluster.go at lines 1919-1925 and 463-464 to match the
CLI wording by asserting the substring “delete protection is active on cluster”;
leave the existing guidance assertion unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 3e2fbc84-6416-4c9d-b6b9-74da003f43d7

📥 Commits

Reviewing files that changed from the base of the PR and between 83784d2 and 5d75dee.

📒 Files selected for processing (10)
  • cmd/create/cluster/cmd.go
  • cmd/create/cluster/cmd_test.go
  • cmd/dlt/cluster/cmd.go
  • cmd/dlt/cluster/cmd_test.go
  • cmd/edit/cluster/cmd.go
  • cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml
  • pkg/ocm/clusters.go
  • pkg/ocm/delete_protection_test.go
  • tests/e2e/test_rosacli_cluster.go
  • tests/e2e/test_rosacli_cluster_post.go
🚧 Files skipped from review as they are similar to previous changes (8)
  • cmd/rosa/structure_test/command_args/rosa/create/cluster/command_args.yml
  • pkg/ocm/clusters.go
  • cmd/edit/cluster/cmd.go
  • cmd/create/cluster/cmd_test.go
  • tests/e2e/test_rosacli_cluster_post.go
  • cmd/dlt/cluster/cmd.go
  • pkg/ocm/delete_protection_test.go
  • cmd/create/cluster/cmd.go

Comment thread tests/e2e/test_rosacli_cluster.go Outdated
Comment thread tests/e2e/test_rosacli_cluster.go Outdated
@michaelryanmcneill

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread cmd/dlt/cluster/cmd.go Outdated
Comment thread cmd/create/cluster/cmd.go Outdated
Comment thread cmd/create/cluster/cmd.go Outdated
Comment thread cmd/create/cluster/cmd.go Outdated
Comment thread tests/e2e/test_rosacli_cluster.go Outdated
@michaelryanmcneill

Copy link
Copy Markdown
Contributor Author

Lint seems to be failing due to issues unrelated to this PR. make lint locally runs fine.

@michaelryanmcneill

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@amandahla

Copy link
Copy Markdown
Contributor

@olucasfreitas I think the lint failure is related to this PR #3345 that touched files from before the new-from-rev, raising old issues.

Will the contributor submit a new one for fixing lint?

@michaelryanmcneill

Copy link
Copy Markdown
Contributor Author

Yay! All e2es passed, ready for final review and merge @olucasfreitas @amandahla.

Comment thread pkg/ocm/delete_protection_test.go Outdated
@amandahla

Copy link
Copy Markdown
Contributor

@michaelryanmcneill on my side, all good, I left a minor comment regarding adding a test.
Lint will be fixed in further PR (probably you will need to rebase soon)

@amandahla

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 15, 2026
Comment thread pkg/ocm/clusters.go Outdated
…e cluster

Enable --enable-delete-protection on cluster create (Classic and HCP)
via post-create OCM PATCH, matching the existing edit-cluster flag.
Add GetClusterDeletionProtection to pkg/ocm for live sub-resource GET.

Signed-off-by: michaelryanmcneill <michael@michaelryanmcneill.com>
@michaelryanmcneill

Copy link
Copy Markdown
Contributor Author

All fixed @olucasfreitas @amandahla! Once the lint issue is fixed, I'll rebase and then we can merge.

@amandahla

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 15, 2026
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amandahla, michaelryanmcneill

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

The pull request process is described 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

@openshift-merge-bot
openshift-merge-bot Bot merged commit 28619c9 into openshift:master Jul 15, 2026
12 of 16 checks passed
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@michaelryanmcneill: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/security 918911c link false /test security
ci/prow/govulncheck 918911c link false /test govulncheck

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants