Skip to content

[SREP-4895] Fallback to deleted_cluster endpoint to get cluster information.#898

Open
bergmannf wants to merge 1 commit into
openshift:masterfrom
bergmannf:SREP-4895-fallback-to-deleted-cluster
Open

[SREP-4895] Fallback to deleted_cluster endpoint to get cluster information.#898
bergmannf wants to merge 1 commit into
openshift:masterfrom
bergmannf:SREP-4895-fallback-to-deleted-cluster

Conversation

@bergmannf
Copy link
Copy Markdown
Contributor

@bergmannf bergmannf commented May 20, 2026

Summary by CodeRabbit

  • New Features
    • Cluster lookup now searches deleted clusters when no active cluster matches the search query.
    • Users can retrieve and access archived cluster information using the same search parameters used for active clusters.
    • Enhanced cluster discovery provides comprehensive search coverage across both active and archived cluster resources.
    • Improves accessibility to historical cluster data.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Walkthrough

The PR extends the GetCluster function to check for deleted clusters when no matching active cluster or subscription is found. It introduces a new client for the deleted-clusters management API endpoint and implements fallback logic that queries deleted clusters using the existing search string before raising a "no clusters found" error.

Changes

Deleted Cluster Lookup Fallback

Layer / File(s) Summary
Deleted-cluster lookup in GetCluster
pkg/utils/utils.go
GetCluster creates a deletedClustersResource client and adds fallback logic that queries the deleted_clusters endpoint using the existing clustersSearch string, returning exactly one matching deleted cluster or erroring if multiple matches exist. If none match in deleted clusters, it continues to the existing final "no subscriptions or clusters" error.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning Ginkgo tests lack meaningful assertion messages. 25 assertions in cmd/setup/setup_test.go and 7 in cmd/promote/saas/saas_test.go use HaveOccurred()/BeNil() without helpful context. Add meaningful messages to all Expect() assertions. Replace bare Expect(err).To(HaveOccurred()) with Expect(err).To(HaveOccurred(), "failed to validate input") to help diagnose failures.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a fallback to the deleted_cluster endpoint for cluster information retrieval.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 PR contains no Ginkgo tests; only standard Go unit tests using testing.T. Custom check for Ginkgo test name stability is not applicable.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests added. The PR adds unit tests (not e2e) for promote/servicelog that test business logic and file operations without Kubernetes interaction.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR modifies pkg/utils/utils.go, a utility package in the osdctl CLI tool repo. No Ginkgo e2e tests are added; the check is not applicable to this codebase which contains no test files.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies utility code in CLI tool, not deployment manifests or operators. No scheduling constraints or K8s resource definitions introduced.
Ote Binary Stdout Contract ✅ Passed The PR modifies only GetCluster() utility function with no stdout writes in the new code. All changes are in pkg/utils/utils.go utility package, not process-level entry points.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR modifies pkg/utils/utils.go, a utility function library, not Ginkgo e2e tests. The custom check applies only to new Ginkgo e2e tests (It(), Describe(), etc.), which are not present in this PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@openshift-ci openshift-ci Bot requested review from sam-nguyen7 and zmird-r May 20, 2026 09:20
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 20, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bergmannf

The full list of commands accepted by this bot can be found here.

The pull request process is described 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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 20, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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/utils/utils.go`:
- Line 153: Change the non-idiomatic capitalized error messages and switch to
proper Go error wrapping: replace "Can't retrieve deleted clusters for key '%s':
'%v'" with a lowercase message and use %w to wrap the underlying error (e.g.,
"can't retrieve deleted clusters for key %q: %w"), and make the same adjustments
for the other occurrences of "Can't retrieve..." in this file (the instances at
the other locations with the same pattern should be lowercased and use %w
instead of %v) so error wrapping and ST1005 style are satisfied.
🪄 Autofix (Beta)

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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6c61175d-a80a-4fc7-87ca-edb64bfa0bfb

📥 Commits

Reviewing files that changed from the base of the PR and between d3f424c and a5e9758.

📒 Files selected for processing (1)
  • pkg/utils/utils.go

Comment thread pkg/utils/utils.go
// If we get here we might still be able to get some information from the deleted_clusters information:
deletedClustersResponse, err := deletedClustersResource.List().Search(clustersSearch).Size(1).Send()
if err != nil {
err = fmt.Errorf("Can't retrieve deleted clusters for key '%s': '%v'", key, err)
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot May 20, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify non-idiomatic capitalized fmt.Errorf strings and %v wrapping in this file
rg -n 'fmt\.Errorf\("[A-Z]' pkg/utils/utils.go
rg -n 'fmt\.Errorf\([^"]*%v' pkg/utils/utils.go

Repository: openshift/osdctl

Length of output: 383


🏁 Script executed:

# Check the exact content around line 153 and line 166
sed -n '150,170p' pkg/utils/utils.go

Repository: openshift/osdctl

Length of output: 820


🏁 Script executed:

# Get full context of all fmt.Errorf calls to understand if others need fixing too
sed -n '83p;130p;153p;166,167p;189p' pkg/utils/utils.go

Repository: openshift/osdctl

Length of output: 453


Fix non-idiomatic error message capitalization and use proper error wrapping in fmt.Errorf calls.

Multiple fmt.Errorf calls in this file violate ST1005. Line 153 should use %w instead of %v for error wrapping, and both lines 153 and 166 use capitalized error messages that should be lowercase. Similar issues appear at lines 83 and 130.

Proposed fix
-		err = fmt.Errorf("Can't retrieve deleted clusters for key '%s': '%v'", key, err)
+		err = fmt.Errorf("can't retrieve deleted clusters for key %q: %w", key, err)
@@
-			"There are %d deleted clusters with identifier or name '%s'",
+			"there are %d deleted clusters with identifier or name '%s'",

Also applies to: 83, 130 (same pattern: "Can't retrieve..." with %v instead of %w)

🧰 Tools
🪛 golangci-lint (2.12.2)

[error] 153-153: ST1005: error strings should not be capitalized

(staticcheck)

🤖 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 `@pkg/utils/utils.go` at line 153, Change the non-idiomatic capitalized error
messages and switch to proper Go error wrapping: replace "Can't retrieve deleted
clusters for key '%s': '%v'" with a lowercase message and use %w to wrap the
underlying error (e.g., "can't retrieve deleted clusters for key %q: %w"), and
make the same adjustments for the other occurrences of "Can't retrieve..." in
this file (the instances at the other locations with the same pattern should be
lowercased and use %w instead of %v) so error wrapping and ST1005 style are
satisfied.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same capitalization is used as in all other messages - maintaining consistency is probably more useful than fixing just this one occurrence.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@bergmannf, that's a fair point — fixing only the newly added line while leaving the same pattern at lines 83 and 130 unchanged would indeed create inconsistency.

Would you like me to open a follow-up issue to track a style cleanup across the whole file (lowercasing error strings and switching %v to %w where appropriate), so it can be addressed holistically in a dedicated PR?

@bergmannf
Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 20, 2026

@bergmannf: 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/lint a5e9758 link true /test lint
ci/prow/format a5e9758 link true /test format

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant