Skip to content

MGMT-24834: Standalone cluster import fails — assisted-service fails to set ClusterDeployment.spec.installed after Day1 completion - #10693

Open
rivkyrizel wants to merge 1 commit into
openshift:masterfrom
rivkyrizel:MGMT-24557
Open

MGMT-24834: Standalone cluster import fails — assisted-service fails to set ClusterDeployment.spec.installed after Day1 completion#10693
rivkyrizel wants to merge 1 commit into
openshift:masterfrom
rivkyrizel:MGMT-24557

Conversation

@rivkyrizel

@rivkyrizel rivkyrizel commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

When a standalone cluster completes Day1 installation, handleClusterInstalled() in clusterdeployments_controller.go updates the AgentClusterInstall metadata and status conditions but never sets ClusterDeployment.Spec.Installed = true.
The assisted-service reconciler doesn't notice because isInstalled() has a fallback that checks the AgentClusterInstall condition, but external components like Hive and MCE check Spec.Installed directly - since it remains false, standalone cluster import fails.
The fix sets clusterDeployment.Spec.Installed = true and persists the ClusterDeployment after successful metadata update, matching the existing pattern in local_cluster_import_controller.go. A unit test was added to verify Spec.Installed is set to true after Day1 completion.

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

Summary by CodeRabbit

  • Bug Fixes

    • Cluster deployments are now marked as installed only after cluster metadata updates complete successfully.
    • Errors encountered while saving the installed status are now reported immediately.
  • Tests

    • Added coverage to verify installed clusters are marked correctly and receive the expected completion status.

…to set ClusterDeployment.spec.installed after Day1 completion
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 22, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 22, 2026

Copy link
Copy Markdown

@rivkyrizel: This pull request references MGMT-24557 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

When a standalone cluster completes Day1 installation, handleClusterInstalled() in clusterdeployments_controller.go updates the AgentClusterInstall metadata and status conditions but never sets ClusterDeployment.Spec.Installed = true.
The assisted-service reconciler doesn't notice because isInstalled() has a fallback that checks the AgentClusterInstall condition, but external components like Hive and MCE check Spec.Installed directly - since it remains false, standalone cluster import fails. The fix sets clusterDeployment.Spec.Installed = true and persists the ClusterDeployment after successful metadata update, matching the existing pattern in local_cluster_import_controller.go. A unit test was added to verify Spec.Installed is set to true after Day1 completion.

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Walkthrough

The controller now marks a cluster deployment installed only after metadata updates succeed, returns persistence errors through status updates, and adds reconciliation coverage for Day1 completion.

Changes

Cluster installation completion

Layer / File(s) Summary
Gate and validate installed-state persistence
internal/controller/controllers/clusterdeployments_controller.go, internal/controller/controllers/clusterdeployments_controller_test.go
The controller gates Spec.Installed on successful metadata updates, handles r.Update failures through updateStatus, and tests the installed backend state and completion reason.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: andrej1991, rccrdpccl

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 The added Ginkgo test title is a fixed string; no dynamic or volatile identifiers appear in changed test names.
Test Structure And Quality ✅ Passed The new It block is single-purpose, uses shared BeforeEach/AfterEach fake-client setup, has no cluster waits/timeouts, and follows nearby test patterns.
Microshift Test Compatibility ✅ Passed The added Ginkgo case is a controller unit test using fake clients/mocks, not an e2e test, so MicroShift compatibility rules don’t apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The added Ginkgo test is a controller unit test using mocks/fake client, with no node/topology assumptions or SNO-sensitive scheduling.
Topology-Aware Scheduling Compatibility ✅ Passed Change only updates ClusterDeployment.Spec.Installed and a unit test; no pod scheduling, affinities, replicas, node selectors, or topology-aware logic added.
Ote Binary Stdout Contract ✅ Passed No process-level stdout writes were added; the only print is to GinkgoWriter inside an It block, which is allowed.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed New Ginkgo case is a unit test using fake client/mocks; it doesn't create external connections or hardcode IPv4/host assumptions.
No-Weak-Crypto ✅ Passed Changed code only sets ClusterDeployment.Spec.Installed and adds a test; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons were introduced.
Container-Privileges ✅ Passed PR only changes Go controller/test files; no container/K8s manifests or privilege settings (privileged, hostNetwork, hostPID, allowPrivilegeEscalation, SYS_ADMIN, root) were added.
No-Sensitive-Data-In-Logs ✅ Passed PASS: the changed controller only adds generic error logging around metadata/status updates; no passwords, tokens, PII, hostnames, or customer data are logged.
Title check ✅ Passed The title clearly describes the main fix: setting ClusterDeployment.spec.installed after Day1 completion for standalone cluster import.
Description check ✅ Passed The description has solid summary, motivation, and context, but it leaves issue linkage and testing details incomplete.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 22, 2026
@openshift-ci
openshift-ci Bot requested review from carbonin and yoavsc0302 July 22, 2026 10:33
@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@rivkyrizel rivkyrizel changed the title MGMT-24557: Standalone cluster import fails — assisted-service fails to set ClusterDeployment.spec.installed after Day1 completion MGMT-24834: Standalone cluster import fails — assisted-service fails to set ClusterDeployment.spec.installed after Day1 completion Jul 22, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 22, 2026

Copy link
Copy Markdown

@rivkyrizel: This pull request references MGMT-24834 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

When a standalone cluster completes Day1 installation, handleClusterInstalled() in clusterdeployments_controller.go updates the AgentClusterInstall metadata and status conditions but never sets ClusterDeployment.Spec.Installed = true.
The assisted-service reconciler doesn't notice because isInstalled() has a fallback that checks the AgentClusterInstall condition, but external components like Hive and MCE check Spec.Installed directly - since it remains false, standalone cluster import fails. The fix sets clusterDeployment.Spec.Installed = true and persists the ClusterDeployment after successful metadata update, matching the existing pattern in local_cluster_import_controller.go. A unit test was added to verify Spec.Installed is set to true after Day1 completion.

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

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 openshift-eng/jira-lifecycle-plugin repository.

@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)
internal/controller/controllers/clusterdeployments_controller_test.go (1)

2388-2413: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a failure-path regression test for the installation gate.

This test covers only successful metadata updates, so it would still pass if Spec.Installed were persisted before metadata failure. Add a case that makes credential/secret metadata persistence fail and assert that ClusterDeployment.Spec.Installed remains false and the expected status error is recorded.

Based on the supplied PR objective to gate installed-state persistence on successful metadata updates.

🤖 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 `@internal/controller/controllers/clusterdeployments_controller_test.go` around
lines 2388 - 2413, Add a separate failure-path test alongside the successful
“should set ClusterDeployment.Spec.Installed” case that makes credential or
secret metadata persistence fail, then reconcile and assert Spec.Installed
remains false and the expected status error is recorded. Configure the relevant
mock expectation to return the failure while preserving the installation-gate
setup and verify the resulting ClusterDeployment status condition.
🤖 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 `@internal/controller/controllers/clusterdeployments_controller_test.go`:
- Around line 2388-2413: Add a separate failure-path test alongside the
successful “should set ClusterDeployment.Spec.Installed” case that makes
credential or secret metadata persistence fail, then reconcile and assert
Spec.Installed remains false and the expected status error is recorded.
Configure the relevant mock expectation to return the failure while preserving
the installation-gate setup and verify the resulting ClusterDeployment status
condition.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7562b0fe-9abe-4d5b-89c7-cccb1862cb79

📥 Commits

Reviewing files that changed from the base of the PR and between 37c158b and 72a3fb5.

📒 Files selected for processing (2)
  • internal/controller/controllers/clusterdeployments_controller.go
  • internal/controller/controllers/clusterdeployments_controller_test.go

@rivkyrizel

Copy link
Copy Markdown
Contributor Author

/retest-required

@openshift-ci

openshift-ci Bot commented Jul 26, 2026

Copy link
Copy Markdown

@rivkyrizel: 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/e2e-agent-compact-ipv4-iso-no-registry 72a3fb5 link false /test e2e-agent-compact-ipv4-iso-no-registry
ci/prow/edge-e2e-ai-operator-disconnected-capi 72a3fb5 link true /test edge-e2e-ai-operator-disconnected-capi

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.

@carbonin carbonin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can review https://github.com/openshift/hive/blob/master/docs/enhancements/cluster-install-apis.md to understand the integration a bit better. If there are issues with this flag or moving conditions to the clusterdeployment from the cluster install, check the hive logs or ask that team for help.

if err != nil {
log.WithError(err).Error("failed to update cluster metadata")
} else {
clusterDeployment.Spec.Installed = true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should not do this. This is hive's job based on the conditions.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants