From 6fc3f1d94194cc9544ae4579fbab0c9d36bf2f1c Mon Sep 17 00:00:00 2001 From: savio87 Date: Wed, 5 Aug 2026 11:47:19 +0530 Subject: [PATCH 1/3] OCPBUGS-60640: return clean error for upgrade status on HyperShift clusters --- pkg/cli/admin/upgrade/status/status.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/cli/admin/upgrade/status/status.go b/pkg/cli/admin/upgrade/status/status.go index 26f5be1be5..105100e541 100644 --- a/pkg/cli/admin/upgrade/status/status.go +++ b/pkg/cli/admin/upgrade/status/status.go @@ -207,6 +207,16 @@ func (o *options) Run(ctx context.Context) error { return fmt.Errorf("no cluster operator information available - you must be connected to an OpenShift version 4 server") } + if o.mockData.cvPath == "" { + infra, err := o.ConfigClient.ConfigV1().Infrastructures().Get(ctx, "cluster", metav1.GetOptions{}) + if err != nil { + return err + } + if infra.Status.ControlPlaneTopology == configv1.ExternalTopologyMode { + return fmt.Errorf("upgrade status is not supported on Hosted Control Plane (HyperShift) clusters") + } + } + progressing := findClusterOperatorStatusCondition(cv.Status.Conditions, configv1.OperatorProgressing) if progressing == nil { return fmt.Errorf("no current %s info, see `oc describe clusterversion` for more details.\n", configv1.OperatorProgressing) From ee86463e543393620aa7008964dd5f3c51a9eb81 Mon Sep 17 00:00:00 2001 From: savio87 Date: Wed, 5 Aug 2026 11:52:53 +0530 Subject: [PATCH 2/3] wrap infrastructure lookup error with context Co-authored-by: Cursor --- pkg/cli/admin/upgrade/status/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cli/admin/upgrade/status/status.go b/pkg/cli/admin/upgrade/status/status.go index 105100e541..c07a11124f 100644 --- a/pkg/cli/admin/upgrade/status/status.go +++ b/pkg/cli/admin/upgrade/status/status.go @@ -210,7 +210,7 @@ func (o *options) Run(ctx context.Context) error { if o.mockData.cvPath == "" { infra, err := o.ConfigClient.ConfigV1().Infrastructures().Get(ctx, "cluster", metav1.GetOptions{}) if err != nil { - return err + return fmt.Errorf("failed to get cluster infrastructure: %w", err) } if infra.Status.ControlPlaneTopology == configv1.ExternalTopologyMode { return fmt.Errorf("upgrade status is not supported on Hosted Control Plane (HyperShift) clusters") From f037b742ca4df8ee3fce846f2dcc36763b04aaa1 Mon Sep 17 00:00:00 2001 From: savio87 Date: Fri, 7 Aug 2026 15:41:30 +0530 Subject: [PATCH 3/3] OCPBUGS-60640: move isHostedCluster to shared status package --- pkg/cli/admin/upgrade/recommend/alerts.go | 6 +----- pkg/cli/admin/upgrade/recommend/alerts_test.go | 3 ++- pkg/cli/admin/upgrade/status/status.go | 7 ++++++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/cli/admin/upgrade/recommend/alerts.go b/pkg/cli/admin/upgrade/recommend/alerts.go index f6612f48eb..d51c34a39a 100644 --- a/pkg/cli/admin/upgrade/recommend/alerts.go +++ b/pkg/cli/admin/upgrade/recommend/alerts.go @@ -286,7 +286,7 @@ func (o *options) alertsEvaluatedByCVO(ctx context.Context) (bool, error) { // if the AcceptRisks feature gate is enabled AND oc is not running against a hosted cluster, // the CVO is handling alerts and will generate the Recommended condition if needed - return isAcceptRisksEnabled(featureGates, cv.Status.Desired.Version) && !isHostedCluster(infrastructure), nil + return isAcceptRisksEnabled(featureGates, cv.Status.Desired.Version) && !status.IsHostedCluster(infrastructure), nil } // isAcceptRisksEnabled checks to see if the 'ClusterUpdateAcceptRisks' feature gate is enabled @@ -307,7 +307,3 @@ func isAcceptRisksEnabled(featureGate *configv1.FeatureGate, clusterVersion stri } return false } - -func isHostedCluster(i *configv1.Infrastructure) bool { - return i != nil && i.Status.ControlPlaneTopology == configv1.ExternalTopologyMode -} diff --git a/pkg/cli/admin/upgrade/recommend/alerts_test.go b/pkg/cli/admin/upgrade/recommend/alerts_test.go index 6566e9710d..95dd04ed16 100644 --- a/pkg/cli/admin/upgrade/recommend/alerts_test.go +++ b/pkg/cli/admin/upgrade/recommend/alerts_test.go @@ -5,6 +5,7 @@ import ( configv1 "github.com/openshift/api/config/v1" "github.com/openshift/api/features" + "github.com/openshift/oc/pkg/cli/admin/upgrade/status" ) func TestIsAcceptRisksEnabled(t *testing.T) { @@ -122,7 +123,7 @@ func TestIsHypershiftEnabled(t *testing.T) { }, } { t.Run(testCase.name, func(t *testing.T) { - actual := isHostedCluster(testCase.infrastructure) + actual := status.IsHostedCluster(testCase.infrastructure) if actual != testCase.expected { t.Errorf("%v != %v", actual, testCase.expected) diff --git a/pkg/cli/admin/upgrade/status/status.go b/pkg/cli/admin/upgrade/status/status.go index c07a11124f..3f34b7fe5b 100644 --- a/pkg/cli/admin/upgrade/status/status.go +++ b/pkg/cli/admin/upgrade/status/status.go @@ -212,7 +212,7 @@ func (o *options) Run(ctx context.Context) error { if err != nil { return fmt.Errorf("failed to get cluster infrastructure: %w", err) } - if infra.Status.ControlPlaneTopology == configv1.ExternalTopologyMode { + if IsHostedCluster(infra) { return fmt.Errorf("upgrade status is not supported on Hosted Control Plane (HyperShift) clusters") } } @@ -394,6 +394,11 @@ func findClusterOperatorStatusCondition(conditions []configv1.ClusterOperatorSta return nil } +// IsHostedCluster returns true if the cluster is a Hosted Control Plane (HyperShift) cluster. +func IsHostedCluster(i *configv1.Infrastructure) bool { + return i != nil && i.Status.ControlPlaneTopology == configv1.ExternalTopologyMode +} + func getMCOImagePullSpec(deployment *appsv1.Deployment) string { if deployment == nil { return ""