Skip to content

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

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

OCPBUGS-60640: return clean error for upgrade status on HyperShift clusters#2347
savio87 wants to merge 2 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.
    • 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: 6cce1b10-fd98-4028-9092-92b365293f5a

📥 Commits

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

📒 Files selected for processing (1)
  • 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. Mock-data execution skips this validation.

Changes

Upgrade status validation

Layer / File(s) Summary
Live cluster topology check
pkg/cli/admin/upgrade/status/status.go
Live executions retrieve the cluster Infrastructure resource, return retrieval errors, and report external control-plane topology as unsupported. Mock-data execution skips the check.

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

Suggested reviewers: atiratree, tchap

🚥 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 describes the clean error added for oc adm upgrade status on HyperShift clusters.
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 only status.go and adds no Ginkgo tests or test titles; related tests use static Go test function names.
Test Structure And Quality ✅ Passed The PR adds no Ginkgo tests or It blocks; status package tests use standard Go testing, so the listed Ginkgo quality requirements are not applicable.
Microshift Test Compatibility ✅ Passed The pull request adds no Ginkgo e2e tests; it changes only status.go, so no MicroShift-incompatible test APIs or assumptions are introduced.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The pull request changes only pkg/cli/admin/upgrade/status/status.go and adds no Ginkgo e2e tests, so the SNO test-compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The only changed file is the upgrade-status CLI; it adds an Infrastructure topology check and no deployment, controller, manifest, replica, affinity, selector, or PDB scheduling constraint.
Ote Binary Stdout Contract ✅ Passed The PR only adds an infrastructure lookup and fmt.Errorf returns inside options.Run; it adds no OTE process-level stdout write or logging setup change.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The diff changes only pkg/cli/admin/upgrade/status/status.go and adds no Ginkgo e2e tests or network-dependent test code.
No-Weak-Crypto ✅ Passed The PR adds only Infrastructure lookup and topology/error handling; added lines contain no weak crypto algorithms, custom crypto, or secret/token comparisons.
Container-Privileges ✅ Passed The PR changes only status.go (+10 lines); the added code contains no container/Kubernetes manifest or privilege settings such as privileged, hostPID, hostNetwork, SYS_ADMIN, or allowPrivilegeEscal...
No-Sensitive-Data-In-Logs ✅ Passed The diff adds only a fixed HyperShift error and context around an existing API error; it logs no passwords, tokens, keys, 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?

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

Labels

jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. 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. 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