Skip to content

Fix console plugin failing when hosted clusters are defined without SSH keys - #6636

Merged
KevinFCormier merged 3 commits into
stolostron:mainfrom
dror1212:fix/handle-hosted-clusters-without-ssh-key
Aug 10, 2026
Merged

Fix console plugin failing when hosted clusters are defined without SSH keys#6636
KevinFCormier merged 3 commits into
stolostron:mainfrom
dror1212:fix/handle-hosted-clusters-without-ssh-key

Conversation

@dror1212

@dror1212 dror1212 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

Ticket Summary (Title):
Handle HostedClusters without an SSH key

Ticket Link:
N/A — this fix does not have an ACM Jira ticket, and GitHub Issues are disabled for this repository.

Type of Change:

  • 🐞 Bug Fix
  • ✨ Feature
  • 🔧 Refactor
  • 💸 Tech Debt
  • 🧪 Test-related
  • 📄 Docs

✅ Checklist

General

  • PR title follows the convention (e.g. ACM-12340 Fix bug with...)
  • Code builds and runs locally without errors
  • No console logs, commented-out code, or unnecessary files
  • All commits are meaningful and well-labeled
  • All new display strings are externalized for localization (English only)
  • (Nice to have) JSDoc comments added for new functions and interfaces

If Feature

  • UI/UX reviewed (if applicable)
  • All acceptance criteria met
  • Unit test coverage added or updated
  • Relevant documentation or comments included

If Bugfix

  • Root cause and fix summary are documented in the ticket (for future reference / errata)
  • Fix tested thoroughly and resolves the issue
  • Test(s) added to prevent regression

🗒️ Notes for Reviewers

HyperShift defines HostedCluster.spec.sshKey as optional. The cluster resource mapping guarded spec, but accessed sshKey.name without guarding the optional sshKey. As a result, listing a valid HostedCluster without an SSH key threw Cannot read properties of undefined (reading 'name') and broke the managed clusters page.

This change safely accesses the optional SSH key reference and updates the console-owned HostedCluster interface to reflect the HyperShift API contract. A regression test verifies that a HostedCluster without an SSH key is mapped successfully.

Validation:

  • npm run check — passed
  • npm test — 532 frontend suites and all backend tests passed; one unrelated Policy wizard test failed from a missing parallel HTTP mock
  • npm test -- --runInBand src/wizards/Governance/Policy/policyWizard.test.tsx — passed (9/9) when rerun in isolation
  • npm test -- --runInBand src/resources/utils/get-cluster.test.ts — passed, including the new regression case

Summary by CodeRabbit

  • Bug Fixes
    • Hosted clusters can now be configured without an SSH key.
    • Cluster secret handling no longer includes empty or invalid secret names when optional credentials are missing.
    • Improved compatibility with hosted-cluster configurations where pull-secret or SSH-key details are omitted.

@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown

Hi @dror1212. Thanks for your PR.

I'm waiting for a stolostron 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 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@KevinFCormier, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 21a42e1e-3709-40b3-9976-baf0cfc5f53d

📥 Commits

Reviewing files that changed from the base of the PR and between 5676fdf and 757dca1.

📒 Files selected for processing (2)
  • frontend/src/resources/hosted-cluster.ts
  • frontend/src/resources/utils/get-cluster.ts
📝 Walkthrough

Walkthrough

HostedCluster.spec.pullSecret and sshKey are now optional. getCluster filters missing secret references. A test covers hosted clusters without an SSH key.

Changes

HostedCluster secret handling

Layer / File(s) Summary
Optional secret contract and extraction
frontend/src/resources/hosted-cluster.ts, frontend/src/resources/utils/get-cluster.ts
The secret references are optional. getCluster safely extracts available secret names without adding empty strings.
Missing SSH key validation
frontend/src/resources/utils/get-cluster.test.ts
The test verifies that a hosted cluster without an SSH key returns only the pull-secret name.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix for HostedClusters without SSH keys.
Description check ✅ Passed The description follows the template and documents the bug, fix, regression test, validation, and unrelated test failure.
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.
✨ 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.

@dror1212
dror1212 marked this pull request as ready for review August 4, 2026 09:31
@dror1212 dror1212 changed the title Fix hosted clusters without SSH keys Fix console plugin failing while hosted clusters without SSH keys Aug 4, 2026
@dror1212 dror1212 changed the title Fix console plugin failing while hosted clusters without SSH keys Fix console plugin failing when hosted clusters are defined without SSH keys Aug 4, 2026
@fxiang1

fxiang1 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@fxiang1

fxiang1 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

/retest

@dror1212

dror1212 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

The MCE enterprise-contract checks are still failing after /retest, but I don’t have permission to view the detailed Konflux logs. Could someone with access take a look and let me know if I need to change anything in this PR?

@fxiang1

fxiang1 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Hi @dror1212 we have opened a konflux issue regarding the failure https://redhat.atlassian.net/browse/KFLUXSPRT-8665.

@KevinFCormier do you think we can manually merge this one?

Signed-off-by: dror1212 <drortal12@gmail.com>
Signed-off-by: dror1212 <drortal12@gmail.com>
@KevinFCormier
KevinFCormier force-pushed the fix/handle-hosted-clusters-without-ssh-key branch from 98c3271 to 5676fdf Compare August 10, 2026 14:56

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

🤖 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 `@frontend/src/resources/hosted-cluster.ts`:
- Line 1: Add the required Open Cluster Management copyright comment as the
first line of hosted-cluster.ts, before the import of IResource and
IResourceDefinition.
- Around line 1-3: Update the imports in hosted-cluster.ts to use type-only
imports for IResource, IResourceDefinition, and Cluster, since they are only
referenced as types; preserve their existing module sources and usage.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 77898ef3-a837-4d02-855e-2592eb48feac

📥 Commits

Reviewing files that changed from the base of the PR and between 98c3271 and 5676fdf.

📒 Files selected for processing (2)
  • frontend/src/resources/hosted-cluster.ts
  • frontend/src/resources/utils/get-cluster.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/resources/utils/get-cluster.ts

@@ -1,8 +1,9 @@
import { IResource, IResourceDefinition } from './resource'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the required source header.

Line 1 starts with an import. Add /* Copyright Contributors to the Open Cluster Management project */ as the first line.

🤖 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 `@frontend/src/resources/hosted-cluster.ts` at line 1, Add the required Open
Cluster Management copyright comment as the first line of hosted-cluster.ts,
before the import of IResource and IResourceDefinition.

Source: Coding guidelines

Comment on lines +1 to +3
import { IResource, IResourceDefinition } from './resource'

import { Cluster } from './utils/get-cluster'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file existence =="
git ls-files | grep -E '(^|/)frontend/src/resources/hosted-cluster\.ts$' || true

if [ -f frontend/src/resources/hosted-cluster.ts ]; then
  echo "== first 80 lines =="
  cat -n frontend/src/resources/hosted-cluster.ts | sed -n '1,80p'

  echo "== import/type mentions in hosted-cluster.ts =="
  rg -n "^[[:space:]]*import |import type|IResource|IResourceDefinition|Cluster" frontend/src/resources/hosted-cluster.ts || true

  echo "== helper exports at candidate files =="
  for f in frontend/src/resources/resource.ts frontend/src/resources/utils/get-cluster.ts; do
    if [ -f "$f" ]; then
      echo "--- $f ---"
      grep -n -E "^(export (interface|type|const|class)|export {)" "$f" | sed -n '1,120p'
    fi
  done
fi

echo "== deterministic check: runtime export usages of the imported symbols in hosted-cluster.ts =="
python3 - <<'PY'
from pathlib import Path
p = Path('frontend/src/resources/hosted-cluster.ts')
if not p.exists():
    print('hosted-cluster.ts missing')
    raise SystemExit(0)
text=p.read_text()
for symbol in ['IResource', 'IResourceDefinition', 'Cluster']:
    # occurrences outside comment/title-ish first line
    occurrences=[]
    for i,line in enumerate(text.splitlines(),1):
        if line.strip().startswith('/* Copyright'):
            continue
        if symbol in line:
            occurrences.append((i,line.strip()))
    import_re=re=re import re
    for i,line in occurrences:
        print(f'{symbol}@{i}: {line}')
PY

Repository: stolostron/console

Length of output: 5867


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== referenced file sizes =="
wc -l frontend/src/resources/utils/get-cluster.ts frontend/src/resources/hosted-cluster.ts frontend/src/resources/resource.ts

echo "== get-cluster export/type context =="
sed -n '230,255p;330,370p' frontend/src/resources/utils/get-cluster.ts | cat -n

echo "== hosted-cluster imports and type usages =="
python3 - <<'PY'
from pathlib import Path
text = Path('frontend/src/resources/hosted-cluster.ts').read_text()
for line_no, line in enumerate(text.splitlines(), 1):
    for symbol in ['IResource', 'IResourceDefinition', 'Cluster']:
        if symbol in line and not line.strip().startswith('/* Copyright'):
            print(f"{symbol}`@line`{line_no}: {line.strip()}")
PY

Repository: stolostron/console

Length of output: 4235


Use type-only imports for type symbols.

IResource, IResourceDefinition, and Cluster are only used for types in this file, so import them with import type to keep runtime imports aligned with the guideline.

Proposed change
-import { IResource, IResourceDefinition } from './resource'
+import type { IResource, IResourceDefinition } from './resource'

-import { Cluster } from './utils/get-cluster'
+import type { Cluster } from './utils/get-cluster'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { IResource, IResourceDefinition } from './resource'
import { Cluster } from './utils/get-cluster'
import type { IResource, IResourceDefinition } from './resource'
import type { Cluster } from './utils/get-cluster'
🤖 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 `@frontend/src/resources/hosted-cluster.ts` around lines 1 - 3, Update the
imports in hosted-cluster.ts to use type-only imports for IResource,
IResourceDefinition, and Cluster, since they are only referenced as types;
preserve their existing module sources and usage.

Source: Coding guidelines

Signed-off-by: Kevin Cormier <kcormier@redhat.com>
@KevinFCormier
KevinFCormier force-pushed the fix/handle-hosted-clusters-without-ssh-key branch from 5676fdf to 757dca1 Compare August 10, 2026 15:01
@KevinFCormier

Copy link
Copy Markdown
Contributor

Hi @dror1212 we have opened a konflux issue regarding the failure https://redhat.atlassian.net/browse/KFLUXSPRT-8665.

@KevinFCormier do you think we can manually merge this one?

@fxiang1 I'm not seeing this issue on the post-merge builds, nor on other PRs. I agree that it is probably a false-positive, but if we merge this code, we might start failing the EC check on post-merge builds. I have tweaked the code a little bit and rebased to see if that will change the build output enough to avoid this problem.

@fxiang1

fxiang1 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Hi @dror1212 we have opened a konflux issue regarding the failure https://redhat.atlassian.net/browse/KFLUXSPRT-8665.
@KevinFCormier do you think we can manually merge this one?

@fxiang1 I'm not seeing this issue on the post-merge builds, nor on other PRs. I agree that it is probably a false-positive, but if we merge this code, we might start failing the EC check on post-merge builds. I have tweaked the code a little bit and rebased to see if that will change the build output enough to avoid this problem.

@KevinFCormier Thanks! I saw this on Kike's PR #6591 as well so I thought it was a common issue.

@KevinFCormier

Copy link
Copy Markdown
Contributor

/ok-to-test

@KevinFCormier

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci

openshift-ci Bot commented Aug 10, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dror1212, KevinFCormier

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

@sonarqubecloud

Copy link
Copy Markdown

@KevinFCormier
KevinFCormier merged commit 0f82a46 into stolostron:main Aug 10, 2026
15 of 17 checks passed
@KevinFCormier

Copy link
Copy Markdown
Contributor

/cherry-pick release-2.17

@KevinFCormier

Copy link
Copy Markdown
Contributor

/cherry-pick release-2.16

@KevinFCormier

Copy link
Copy Markdown
Contributor

/cherry-pick release-2.15

@openshift-cherrypick-robot

Copy link
Copy Markdown
Contributor

@KevinFCormier: new pull request created: #6674

Details

In response to this:

/cherry-pick release-2.17

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.

@openshift-cherrypick-robot

Copy link
Copy Markdown
Contributor

@KevinFCormier: new pull request created: #6675

Details

In response to this:

/cherry-pick release-2.16

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.

@openshift-cherrypick-robot

Copy link
Copy Markdown
Contributor

@KevinFCormier: new pull request created: #6676

Details

In response to this:

/cherry-pick release-2.15

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants