Skip to content

fix: make frontend cluster create idempotent to prevent CS duplicate collisions#6025

Draft
cssjr wants to merge 1 commit into
Azure:mainfrom
cssjr:fix/aro-27951-idempotent-cluster-create
Draft

fix: make frontend cluster create idempotent to prevent CS duplicate collisions#6025
cssjr wants to merge 1 commit into
Azure:mainfrom
cssjr:fix/aro-27951-idempotent-cluster-create

Conversation

@cssjr

@cssjr cssjr commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes ARO-27951: "InvalidRequestContent — Duplicate ARO-HCP cluster name collision" hitting ~7.2% of CI E2E runs
  • Adds idempotency check to the frontend createHCPCluster() path before calling PostCluster, preventing split-brain when Cosmos write fails after CS create succeeds
  • Extracts FindClusterByAzureInfo into a shared ocm package function, deduplicating logic between frontend and backend controller

Root Cause

The frontend's createHCPCluster() performs a two-phase write that is not atomic:

  1. Phase 1: PostCluster to Cluster Service (CS) — creates the cluster record
  2. Phase 2: Cosmos DB transactional batch — creates cluster + operation documents

If Phase 2 fails (transient Cosmos error), the system enters a split-brain state: CS has the cluster, Cosmos does not. When the Azure SDK automatically retries the failed 500:

  1. CreateOrUpdateHCPCluster checks Cosmos → not found → routes to createHCPCluster
  2. PostCluster to CS → CS rejects: "Duplicate ARO-HCP cluster name" (HTTP 400)
  3. Error mapped to InvalidRequestContent → test/request fails

This was confirmed by an identical Stage incident documented in ARO-17939 (comment by Mike Gahagan, 2026-05-20).

Fix

Before calling PostCluster, the frontend now searches CS for an existing cluster with matching Azure metadata (subscription, resource group, resource name, tenant, managed resource group) via ocm.FindClusterByAzureInfo. If an orphaned CS cluster from a prior failed attempt is found, it is reused instead of creating a duplicate.

The backend's ClusterClusterServiceCreate controller already had this idempotency pattern — this PR extracts it into a shared function and applies it to the frontend as well.

Test plan

  • go build for all affected packages (internal/ocm, frontend, backend)
  • go test ./internal/ocm/... — passes
  • go test ./frontend/... — passes
  • go test ./backend/... — all 20+ controller test packages pass
  • make lint — passes
  • Integration tests (make test-integration)
  • E2E validation: monitor branch-ci-Azure-ARO-HCP-main-e2e-integration-e2e-parallel success rate after merge

🤖 Generated with Claude Code

…collisions

The frontend's createHCPCluster() performs a two-phase write: it creates
the cluster in Cluster Service (CS) first, then writes to Cosmos DB. If
the Cosmos write fails, CS has the cluster but the RP doesn't — a
split-brain state. When the Azure SDK automatically retries the failed
500, the retry calls PostCluster again and CS rejects with "Duplicate
ARO-HCP cluster name" (400 InvalidRequestContent).

This was hitting ~7.2% of CI E2E runs (ARO-27951) and was confirmed in
a Stage incident (ARO-17939).

Fix: before calling PostCluster, search CS by Azure metadata
(subscription, resource group, resource name, tenant, managed resource
group) via a new shared FindClusterByAzureInfo function. If an orphaned
CS cluster from a prior failed attempt is found, reuse it instead of
creating a duplicate. This makes the create path idempotent on retry.

Also refactors the backend's ClusterClusterServiceCreate controller to
use the same shared function, eliminating duplicated search logic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cssjr
Once this PR has been reviewed and has the lgtm label, please assign mbarnes 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

@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

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

@cssjr

cssjr commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

/test all

@cssjr

cssjr commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

/assign copilot

@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

@cssjr: GitHub didn't allow me to assign the following users: copilot.

Note that only Azure members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

Details

In response to this:

/assign copilot

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.

@cssjr

cssjr commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

/cc copilot

@cssjr

cssjr commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator Author

/retest

@openshift-ci

openshift-ci Bot commented Jul 11, 2026

Copy link
Copy Markdown

@cssjr: 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/image-updater-images 9b80e44 link true /test image-updater-images
ci/prow/config-change-detection 9b80e44 link true /test config-change-detection
ci/prow/test-unit 9b80e44 link true /test test-unit
ci/prow/lint 9b80e44 link true /test lint
ci/prow/integration 9b80e44 link true /test integration
ci/prow/e2e-parallel 9b80e44 link true /test e2e-parallel
ci/prow/periodic-healthcheck-images 9b80e44 link true /test periodic-healthcheck-images

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant