Skip to content

OCPBUGS-60640: return clean error for upgrade status on HyperShift clusters - #2347

Open
savio87 wants to merge 3 commits into
openshift:mainfrom
savio87:OCPBUGS-60640
Open

OCPBUGS-60640: return clean error for upgrade status on HyperShift clusters#2347
savio87 wants to merge 3 commits into
openshift:mainfrom
savio87:OCPBUGS-60640

Conversation

@savio87

@savio87 savio87 commented Aug 5, 2026

Copy link
Copy Markdown

Summary

oc adm upgrade status crashes on HyperShift/HCP clusters with "Error from server (NotFound): deployments.apps "machine-config-operator" not found" because it assumes the MCO deployment exists.

This adds an early check for Infrastructure.status.controlPlaneTopology == External (the canonical HyperShift detection pattern, already used in recommend/alerts.go) and returns a clean error message before any MCO/MCP API calls.

Bug: https://redhat.atlassian.net/browse/OCPBUGS-60640

Changes

  • Added HyperShift detection in status.go Run() using ExternalTopologyMode check
  • Returns "upgrade status is not supported on Hosted Control Plane (HyperShift) clusters" instead of crashing

Summary by CodeRabbit

  • Bug Fixes
    • Added a clear error when attempting to check upgrade status for unsupported hosted control plane clusters.
    • Upgrade recommendations now consistently recognize hosted clusters.
    • Mock-data execution remains available without this validation.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. labels Aug 5, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@savio87: This pull request references Jira Issue OCPBUGS-60640, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

oc adm upgrade status crashes on HyperShift/HCP clusters with "Error from server (NotFound): deployments.apps "machine-config-operator" not found" because it assumes the MCO deployment exists.

This adds an early check for Infrastructure.status.controlPlaneTopology == External (the canonical HyperShift detection pattern, already used in recommend/alerts.go) and returns a clean error message before any MCO/MCP API calls.

Bug: https://redhat.atlassian.net/browse/OCPBUGS-60640

Changes

  • Added HyperShift detection in status.go Run() using ExternalTopologyMode check
  • Returns "upgrade status is not supported on Hosted Control Plane (HyperShift) clusters" instead of crashing

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.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Aug 5, 2026
@openshift-ci
openshift-ci Bot requested review from atiratree and tchap August 5, 2026 06:18
@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 5, 2026
@openshift-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: savio87
Once this PR has been reviewed and has the lgtm label, please assign wking 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 Aug 5, 2026

Copy link
Copy Markdown
Contributor

Hi @savio87. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@coderabbitai

coderabbitai Bot commented Aug 5, 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: Pro Plus

Run ID: b69321c8-7538-439d-ac42-fb3e3f0f4c78

📥 Commits

Reviewing files that changed from the base of the PR and between ee86463 and f037b74.

📒 Files selected for processing (3)
  • pkg/cli/admin/upgrade/recommend/alerts.go
  • pkg/cli/admin/upgrade/recommend/alerts_test.go
  • pkg/cli/admin/upgrade/status/status.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/cli/admin/upgrade/status/status.go

Walkthrough

The upgrade status command now retrieves the cluster Infrastructure resource during live execution. It returns retrieval errors and rejects clusters with ExternalTopologyMode. Upgrade recommendations use the shared hosted-cluster check. Mock-data execution skips validation.

Changes

Hosted cluster upgrade validation

Layer / File(s) Summary
Live hosted-cluster validation
pkg/cli/admin/upgrade/status/status.go
Live executions retrieve the cluster Infrastructure resource, return retrieval errors, and reject external control-plane topology. The exported IsHostedCluster helper handles nil input.
Recommendation integration
pkg/cli/admin/upgrade/recommend/alerts.go, pkg/cli/admin/upgrade/recommend/alerts_test.go
Upgrade recommendations and the hypershift test use status.IsHostedCluster instead of a local helper.

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

Merge Risk: ⚪ Minimal · up to f037b

The PR adds a localized HyperShift guard that returns a clean unsupported-operation error instead of attempting unavailable upgrade-status resources; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: atiratree, dis016

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the upgrade status behavior change for HyperShift clusters and includes the relevant issue identifier.
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 PR changes no Ginkgo titles. The modified table-driven test uses stable static names such as "hypershift enabled" and "no infrastructure".
Test Structure And Quality ✅ Passed The PR changes no Ginkgo tests. Its only test edit is a standard Go table test that calls status.IsHostedCluster; no cluster resources, waits, or Ginkgo assertions are introduced.
Microshift Test Compatibility ✅ Passed The diff changes three Go files and adds no Ginkgo e2e tests; alerts_test.go only modifies standard testing.T subtests.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds no Ginkgo e2e tests. The only changed test uses Go's testing package and tests helper logic without multi-node assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed The diff changes only CLI upgrade status/recommendation logic and a topology-detection helper; it adds no deployment, operator, controller, or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The diff adds only a helper, call-site, and import. It adds no main/init/suite setup or stdout write; existing fmt.Println and klog calls remain inside command methods.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR changes only three CLI Go files and adds no Ginkgo e2e tests, IPv4 assumptions, or external connectivity requirements.
No-Weak-Crypto ✅ Passed The three changed files add only infrastructure detection and helper reuse; the diff introduces no MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed The full PR diff changes only three Go files and adds no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, or allowPrivilegeEscalation settings.
No-Sensitive-Data-In-Logs ✅ Passed The complete PR diff adds only a static unsupported-cluster error, a helper, and an infrastructure-error wrapper; it introduces no logging of passwords, tokens, PII, hostnames, or customer data.
✨ 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.

@savio87

savio87 commented Aug 5, 2026

Copy link
Copy Markdown
Author

Adds an early Infrastructure.status.controlPlaneTopology == External check (same pattern used in recommend/alerts.go) to return a clean error message on HyperShift clusters before any MCO/MCP API calls. Could a maintainer update the target version on OCPBUGS-60640 and run /ok-to-test? Thanks!

@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: 1

🤖 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/cli/admin/upgrade/status/status.go`:
- Around line 211-213: Wrap the error returned by the Infrastructures().Get call
in the upgrade status flow with fmt.Errorf, adding clear context such as failure
to get the cluster Infrastructure while preserving the original error with %w.
🪄 Autofix

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: Pro Plus

Run ID: 58a5b7f9-3666-4731-ba29-8fbe345e6a2e

📥 Commits

Reviewing files that changed from the base of the PR and between 9c7ccc4 and 6fc3f1d.

📒 Files selected for processing (1)
  • pkg/cli/admin/upgrade/status/status.go

Comment thread pkg/cli/admin/upgrade/status/status.go Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>
}
if infra.Status.ControlPlaneTopology == configv1.ExternalTopologyMode {
return fmt.Errorf("upgrade status is not supported on Hosted Control Plane (HyperShift) clusters")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since there is already

func isHostedCluster(i *configv1.Infrastructure) bool {
	return i != nil && i.Status.ControlPlaneTopology == configv1.ExternalTopologyMode
}

in alerts.go, can we put that helper into a shared package and use that wherever necessary?

@savio87

savio87 commented Aug 7, 2026

Copy link
Copy Markdown
Author

Thanks @tchap — moved isHostedCluster to the status package as IsHostedCluster so it can be shared. Updated recommend/alerts.go and its test to use the shared helper. Let me know if there's anything else to address.

@savio87

savio87 commented Aug 14, 2026

Copy link
Copy Markdown
Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 14, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@savio87: This pull request references Jira Issue OCPBUGS-60640, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @dis016

Details

In response to this:

/jira refresh

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.

@openshift-ci
openshift-ci Bot requested a review from dis016 August 14, 2026 05:44
@savio87

savio87 commented Aug 14, 2026

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 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.

@openshift-ci-robot

Copy link
Copy Markdown

@savio87: This pull request references Jira Issue OCPBUGS-60640, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @dis016

Details

In response to this:

Summary

oc adm upgrade status crashes on HyperShift/HCP clusters with "Error from server (NotFound): deployments.apps "machine-config-operator" not found" because it assumes the MCO deployment exists.

This adds an early check for Infrastructure.status.controlPlaneTopology == External (the canonical HyperShift detection pattern, already used in recommend/alerts.go) and returns a clean error message before any MCO/MCP API calls.

Bug: https://redhat.atlassian.net/browse/OCPBUGS-60640

Changes

  • Added HyperShift detection in status.go Run() using ExternalTopologyMode check
  • Returns "upgrade status is not supported on Hosted Control Plane (HyperShift) clusters" instead of crashing

Summary by CodeRabbit

  • Bug Fixes
  • Added a clear error when attempting to check upgrade status for unsupported hosted control plane clusters.
  • Upgrade recommendations now consistently recognize hosted clusters.
  • Mock-data execution remains available without this validation.

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.

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

Labels

jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants