Skip to content

OCPBUGS-86894: reduce startup API calls and prioritize critical fetches - #16533

Merged
openshift-merge-bot[bot] merged 3 commits into
openshift:mainfrom
logonoff:OCPBUGS-86894-useuser
Jun 9, 2026
Merged

OCPBUGS-86894: reduce startup API calls and prioritize critical fetches#16533
openshift-merge-bot[bot] merged 3 commits into
openshift:mainfrom
logonoff:OCPBUGS-86894-useuser

Conversation

@logonoff

@logonofflogonoff commented Jun 2, 2026

Copy link
Copy Markdown
Member

Analysis / Root cause:

Profiling startup network activity revealed that the useUser hook (which fetches users/~ from the k8s API) uses useK8sGet — a hook with no cross-instance deduplication. Every component that calls useUser() (directly or via useTelemetry()) triggers an independent fetch. With ~10+ component instances mounting during startup, this produced 22 duplicate API calls to the same endpoint.

Additionally, the 3 MB openapi/v2 fetch and multiple terminal/available checks were competing with critical startup resources for bandwidth, with no fetch priority hints to let the browser schedule them appropriately.

Solution description:

  1. useUser: Switch from useK8sGet to useK8sWatchResource, which deduplicates at the Redux/watch infrastructure level. All hook instances share a single underlying watch, reducing users/~ calls from 22 to 1. This also correctly handles impersonation changes since the watch infrastructure reconnects when auth context changes.

  2. Fetch Priority hints (Fetch Priority API):

    • priority: 'high' on the early auth check (api/kubernetes/api) so the browser prioritizes the authentication redirect check
    • priority: 'low' on openapi/v2 (3 MB, used only for form field descriptions — not needed for initial render)
    • priority: 'low' on terminal/available checks (not render-critical)
  3. Remove duplicate fetchSwagger call from actions/k8s.tsapp.tsx already handles the initial fetch and 5-minute polling, so the second call 10 seconds after discovery was redundant.

Performance results

Tested under simulated Fast 3G (1.5 Mbps, 562ms RTT) + 4x CPU throttle, 5 runs each, browser cache cleared between runs. App-ready measured as time until [data-test="page-heading"] h1 is visible.

MetricBefore (main)After (this PR)Improvement
App ready (median)37.0s29.8s-7.1s (19% faster)
App ready (avg)36.2s29.2s-7.0s (19% faster)
Total API calls7347-26 calls (36% fewer)
Total resources loaded134107-27 resources (20% fewer)
users/~ calls221-21 calls
terminal/available calls83-5 calls
Total transfer2,974 KB2,933 KB-41 KB

Screenshots / screen recording:

Test setup:

Two console instances running against the same cluster:

  • :9000 — this PR (OCPBUGS-86894-useuser branch)
  • :9001 — HEAD of main

Both running over HTTP/1.1 with auth disabled, localhost bridge, same OCP 5.0 cluster.

Benchmarked with Playwright using Chrome DevTools Protocol for CPU/network throttling.

Test cases:

  • Verified users/~ is fetched exactly once during startup (was 22x)
  • Verified terminal/available uses priority: 'low' and yields to critical resources
  • Verified openapi/v2 uses priority: 'low' and downloads after critical resources
  • Verified impersonation still works correctly (useK8sWatchResource reconnects on auth change)
  • Verified the app renders the same UI with all features functional
  • Impersonation still works
  • yarn test passes

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

The useK8sGet hook creates a new useState + useEffect per instance with no shared state — every component that mounts independently fetches the same resource. useK8sWatchResource uses the console's watch infrastructure which deduplicates at the Redux store level, so multiple hook instances share a single underlying fetch/watch.

The Fetch Priority API (priority: 'low' / 'high') is supported in Chrome 101+, Edge 101+, and Safari 17.2+. Unsupported browsers silently ignore the hint with no behavioral change.

Summary by CodeRabbit

  • Performance Improvements

    • Early auth API request is now prioritized; OpenAPI/Swagger fetches moved to low‑priority/background.
  • Updates

    • User data now syncs via a watch-based mechanism for more timely updates.
    • Terminal availability checks use lower‑priority network requests.
  • UI / UX

    • New auth‑pending skeleton, slow‑loading message with a refresh action, updated loading fallback, and two new English strings.
  • Tests

    • Updated tests to reflect watch-based user loading and related behaviors.

@openshift-ci-robotopenshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jun 2, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@logonoff: This pull request references Jira Issue OCPBUGS-86894, 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)

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

Details

In response to this:

Analysis / Root cause:

Profiling startup network activity revealed that the useUser hook (which fetches users/~ from the k8s API) uses useK8sGet — a hook with no cross-instance deduplication. Every component that calls useUser() (directly or via useTelemetry()) triggers an independent fetch. With ~10+ component instances mounting during startup, this produced 22 duplicate API calls to the same endpoint.

Additionally, the 3 MB openapi/v2 fetch and multiple terminal/available checks were competing with critical startup resources for bandwidth, with no fetch priority hints to let the browser schedule them appropriately.

Solution description:

  1. useUser: Switch from useK8sGet to useK8sWatchResource, which deduplicates at the Redux/watch infrastructure level. All hook instances share a single underlying watch, reducing users/~ calls from 22 to 1. This also correctly handles impersonation changes since the watch infrastructure reconnects when auth context changes.

  2. Fetch Priority hints (Fetch Priority API):

  • priority: 'high' on the early auth check (api/kubernetes/api) so the browser prioritizes the authentication redirect check
  • priority: 'low' on openapi/v2 (3 MB, used only for form field descriptions — not needed for initial render)
  • priority: 'low' on terminal/available checks (not render-critical)
  1. Remove duplicate fetchSwagger call from actions/k8s.tsapp.tsx already handles the initial fetch and 5-minute polling, so the second call 10 seconds after discovery was redundant.

Performance results

Tested under simulated Fast 3G (1.5 Mbps, 562ms RTT) + 4x CPU throttle, 5 runs each, browser cache cleared between runs. App-ready measured as time until [data-test="page-heading"] h1 is visible.

MetricBefore (main)After (this PR)Improvement
App ready (median)37.0s29.8s-7.1s (19% faster)
App ready (avg)36.2s29.2s-7.0s (19% faster)
Total API calls7347-26 calls (36% fewer)
Total resources loaded134107-27 resources (20% fewer)
users/~ calls221-21 calls
terminal/available calls83-5 calls
Total transfer2,974 KB2,933 KB-41 KB

Screenshots / screen recording:

Test setup:

Two console instances running against the same cluster:

  • :9000 — this PR (OCPBUGS-86894-useuser branch)
  • :9001 — HEAD of main

Both running over HTTP/1.1 with auth disabled, localhost bridge, same OCP 5.0 cluster.

Benchmarked with Playwright using Chrome DevTools Protocol for CPU/network throttling.

Test cases:

  • Verified users/~ is fetched exactly once during startup (was 22x)
  • Verified terminal/available uses priority: 'low' and yields to critical resources
  • Verified openapi/v2 uses priority: 'low' and downloads after critical resources
  • Verified impersonation still works correctly (useK8sWatchResource reconnects on auth change)
  • Verified the app renders the same UI with all features functional
  • yarn test passes

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

The useK8sGet hook creates a new useState + useEffect per instance with no shared state — every component that mounts independently fetches the same resource. useK8sWatchResource uses the console's watch infrastructure which deduplicates at the Redux store level, so multiple hook instances share a single underlying fetch/watch.

The Fetch Priority API (priority: 'low' / 'high') is supported in Chrome 101+, Edge 101+, and Safari 17.2+. Unsupported browsers silently ignore the hint with no behavioral change.

Reviewers and assignees:

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

Copy link
Copy Markdown
Contributor

@logonoff: This pull request references Jira Issue OCPBUGS-86894, 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)
Details

In response to this:

Analysis / Root cause:

Profiling startup network activity revealed that the useUser hook (which fetches users/~ from the k8s API) uses useK8sGet — a hook with no cross-instance deduplication. Every component that calls useUser() (directly or via useTelemetry()) triggers an independent fetch. With ~10+ component instances mounting during startup, this produced 22 duplicate API calls to the same endpoint.

Additionally, the 3 MB openapi/v2 fetch and multiple terminal/available checks were competing with critical startup resources for bandwidth, with no fetch priority hints to let the browser schedule them appropriately.

Solution description:

  1. useUser: Switch from useK8sGet to useK8sWatchResource, which deduplicates at the Redux/watch infrastructure level. All hook instances share a single underlying watch, reducing users/~ calls from 22 to 1. This also correctly handles impersonation changes since the watch infrastructure reconnects when auth context changes.

  2. Fetch Priority hints (Fetch Priority API):

  • priority: 'high' on the early auth check (api/kubernetes/api) so the browser prioritizes the authentication redirect check
  • priority: 'low' on openapi/v2 (3 MB, used only for form field descriptions — not needed for initial render)
  • priority: 'low' on terminal/available checks (not render-critical)
  1. Remove duplicate fetchSwagger call from actions/k8s.tsapp.tsx already handles the initial fetch and 5-minute polling, so the second call 10 seconds after discovery was redundant.

Performance results

Tested under simulated Fast 3G (1.5 Mbps, 562ms RTT) + 4x CPU throttle, 5 runs each, browser cache cleared between runs. App-ready measured as time until [data-test="page-heading"] h1 is visible.

MetricBefore (main)After (this PR)Improvement
App ready (median)37.0s29.8s-7.1s (19% faster)
App ready (avg)36.2s29.2s-7.0s (19% faster)
Total API calls7347-26 calls (36% fewer)
Total resources loaded134107-27 resources (20% fewer)
users/~ calls221-21 calls
terminal/available calls83-5 calls
Total transfer2,974 KB2,933 KB-41 KB

Screenshots / screen recording:

Test setup:

Two console instances running against the same cluster:

  • :9000 — this PR (OCPBUGS-86894-useuser branch)
  • :9001 — HEAD of main

Both running over HTTP/1.1 with auth disabled, localhost bridge, same OCP 5.0 cluster.

Benchmarked with Playwright using Chrome DevTools Protocol for CPU/network throttling.

Test cases:

  • Verified users/~ is fetched exactly once during startup (was 22x)
  • Verified terminal/available uses priority: 'low' and yields to critical resources
  • Verified openapi/v2 uses priority: 'low' and downloads after critical resources
  • Verified impersonation still works correctly (useK8sWatchResource reconnects on auth change)
  • Verified the app renders the same UI with all features functional
  • yarn test passes

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

The useK8sGet hook creates a new useState + useEffect per instance with no shared state — every component that mounts independently fetches the same resource. useK8sWatchResource uses the console's watch infrastructure which deduplicates at the Redux store level, so multiple hook instances share a single underlying fetch/watch.

The Fetch Priority API (priority: 'low' / 'high') is supported in Chrome 101+, Edge 101+, and Safari 17.2+. Unsupported browsers silently ignore the hint with no behavioral change.

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.

@coderabbitai

coderabbitaiBot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

User resource loading now uses a stable watch descriptor; coFetch calls gain explicit priorities (high for early auth, low for deferred Swagger/terminal checks); delayed post-resource Swagger scheduling was removed; an auth-pending skeleton, translations, and styles were added.

Changes

User resource watch update

Layer / File(s)Summary
useUser watch implementation
frontend/packages/console-shared/src/hooks/useUser.ts
useUser switches from a one-time Kubernetes get to useK8sWatchResource with a static userWatchResource descriptor; it reads watched data and conditionally dispatches setUserResource.
useUser tests and mock updates
frontend/packages/console-shared/src/hooks/__tests__/useUser.spec.ts
Tests now mock useK8sWatchResource instead of useK8sGet, update displayName assertions, add referential-equality test for the watch descriptor, and verify Redux dispatch on watched updates after impersonation state changes.

Fetch Request Handling and Prioritization

Layer / File(s)Summary
fetchSwagger priority and tests
frontend/public/module/k8s/swagger.ts, frontend/public/module/k8s/__tests__/swagger.spec.ts
fetchSwagger calls coFetch with { priority: 'low' }; tests updated to expect the priority option in relevant assertions.
App early auth and actions change
frontend/public/components/app.tsx, frontend/public/actions/k8s.ts
Early authenticated Kubernetes fetch now uses { priority: 'high' } and explicitly swallows errors; resource action no longer schedules a delayed fetchSwagger() call.
Terminal availability check priority
frontend/packages/webterminal-plugin/src/components/cloud-shell/cloud-shell-utils.ts
checkTerminalAvailable now calls /api/terminal/available via coFetch with { priority: 'low' }.

Auth-pending skeleton, translations, and styles

Layer / File(s)Summary
DetectContext slow-loading UI
frontend/packages/console-app/src/components/detect-context/DetectContext.tsx
Adds SlowLoadingMessage, local PageSkeleton wrapping LoadingBox, i18n usage, and additional PatternFly imports for the slow-loading UI.
Auth-pending styles, HTML, and locales
frontend/public/style/_layout.scss, frontend/public/index.html, frontend/public/locales/en/public.json, frontend/public/components/cluster-settings/_cluster-settings.scss
Adds .co-auth-pending-driven skeleton state and animations, updates <html> classes with co-auth-pending, adds two public translation keys, and reorders one SCSS declaration in cluster-settings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • openshift/console#16457: Modifies fetchSwagger in the same frontend/public/module/k8s/swagger.ts file with overlapping changes to coFetch request behavior for OpenAPI v2 retrieval.

Suggested labels

verified

Suggested reviewers

  • TheRealJon
  • Leo6Leo
🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check nameStatusExplanation
Title check✅ PassedThe PR title clearly and specifically summarizes the main changes: reducing startup API calls and prioritizing critical fetches using the Fetch Priority API.
Description check✅ PassedThe PR description includes all required template sections: analysis/root cause, solution description, test setup, test cases, and browser conformance. The description is comprehensive with performance metrics and technical rationale.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names✅ PassedNo Ginkgo tests found in PR. Changes only affect TypeScript/Jest tests (useUser.spec.ts, swagger.spec.ts) with stable, deterministic test names containing no dynamic information.
Test Structure And Quality✅ PassedCustom check is for Ginkgo test code quality, but PR contains only Jest tests (JavaScript/TypeScript). No Ginkgo tests exist in PR; check is not applicable.
Microshift Test Compatibility✅ PassedPR contains no new Ginkgo e2e tests—only frontend TypeScript/React code and Jest unit tests. MicroShift compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility✅ PassedNo Ginkgo e2e tests are added in this PR. The changes are entirely frontend/console UI and performance optimizations; test file modifications are Jest unit tests only.
Topology-Aware Scheduling Compatibility✅ PassedPR contains only frontend code (React, SCSS, HTML, JSON) with no deployment manifests or operator code, so topology-aware scheduling check is not applicable.
Ote Binary Stdout Contract✅ PassedPR contains only frontend TypeScript/SCSS/HTML changes; no Go test suite setup code or process-level stdout writes introduced; OTE Binary Stdout Contract check is not applicable.
Ipv6 And Disconnected Network Test Compatibility✅ PassedThis PR contains only frontend TypeScript/JavaScript code changes with Jest unit tests; no Ginkgo e2e tests are added, so the IPv6/disconnected environment compatibility check does not apply.
No-Weak-Crypto✅ PassedNo weak cryptographic algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or insecure secret comparisons introduced in PR changes.
Container-Privileges✅ PassedPR contains no Kubernetes manifests, container configs, or Dockerfiles; no privileged settings found. Check not applicable to frontend-only performance optimization PR.
No-Sensitive-Data-In-Logs✅ PassedNo NEW logging exposing sensitive data introduced. All logging found is pre-existing error handling; PR removes fetchSwagger logging.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
openshift-ciBot requested review from TheRealJon and cajiehJune 2, 2026 20:22
@openshift-ciopenshift-ciBot added component/core Related to console core functionality component/shared Related to console-shared approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 2, 2026
@Leo6Leo

Copy link
Copy Markdown
Contributor

Review and prowpy retest monitoring
/assign @Leo6Leo

@coderabbitaicoderabbitaiBot left a comment

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.

🧹 Nitpick comments (1)
frontend/packages/console-shared/src/hooks/__tests__/useUser.spec.ts (1)

81-95: ⚡ Quick win

Add coverage for the watch-error path.

useUser only dispatches setUserResource when userResourceLoaded && userResourceData && !userResourceError. The new tests cover the success and impersonation cases, but there's no test asserting that a watch error (e.g. [null, true, someError]) suppresses the dispatch. That branch is the most likely to regress silently.

💚 Suggested test to cover the error branch
+ it('should not dispatch setUserResource when the watch reports an error', () => {+ const mockUser = { username: 'testuser@example.com' };++ mockUseSelector.mockReturnValueOnce(mockUser).mockReturnValueOnce(null);+ mockUseK8sWatchResource.mockReturnValue([null, true, new Error('forbidden')]);++ renderHook(() => useUser());++ expect(mockDispatch).not.toHaveBeenCalled();+ });

Want me to open an issue to track this coverage gap?

Also applies to: 152-167

🤖 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/packages/console-shared/src/hooks/__tests__/useUser.spec.ts` around
lines 81 - 95, Add a test in useUser.spec.ts to cover the watch-error branch by
simulating useUser with an existing user (mockUseSelector returns the user) and
mockUseK8sWatchResource returning [null, true, someError] (i.e.,
userResourceLoaded true but userResourceError present), then renderHook(() =>
useUser()) and assert that mockDispatch was NOT called with the setUserResource
action (type 'setUserResource', payload { userResource: ... }); this ensures
useUser's conditional (userResourceLoaded && userResourceData &&
!userResourceError) correctly suppresses dispatch on watch errors.
🤖 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.
Nitpick comments:
In `@frontend/packages/console-shared/src/hooks/__tests__/useUser.spec.ts`:
- Around line 81-95: Add a test in useUser.spec.ts to cover the watch-error
branch by simulating useUser with an existing user (mockUseSelector returns the
user) and mockUseK8sWatchResource returning [null, true, someError] (i.e.,
userResourceLoaded true but userResourceError present), then renderHook(() =>
useUser()) and assert that mockDispatch was NOT called with the setUserResource
action (type 'setUserResource', payload { userResource: ... }); this ensures
useUser's conditional (userResourceLoaded && userResourceData &&
!userResourceError) correctly suppresses dispatch on watch errors.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a2cb42c1-2fff-4d38-b16b-71173bd47241

📥 Commits

Reviewing files that changed from the base of the PR and between 7e6f324 and 3d08b43.

📒 Files selected for processing (7)
  • frontend/packages/console-shared/src/hooks/__tests__/useUser.spec.ts
  • frontend/packages/console-shared/src/hooks/useUser.ts
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/cloud-shell-utils.ts
  • frontend/public/actions/k8s.ts
  • frontend/public/components/app.tsx
  • frontend/public/module/k8s/__tests__/swagger.spec.ts
  • frontend/public/module/k8s/swagger.ts
✅ Files skipped from review due to trivial changes (2)
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/cloud-shell-utils.ts
  • frontend/public/module/k8s/tests/swagger.spec.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • frontend/public/components/app.tsx
  • frontend/packages/console-shared/src/hooks/useUser.ts
  • frontend/public/actions/k8s.ts
  • frontend/public/module/k8s/swagger.ts

@logonoff
logonoffforce-pushed the OCPBUGS-86894-useuser branch 2 times, most recently from bfa581e to aecb812CompareJune 4, 2026 14:38
@openshift-ciopenshift-ciBot added the kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated label Jun 4, 2026

@coderabbitaicoderabbitaiBot left a comment

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.

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/public/components/app.tsx`:
- Around line 88-92: The probe currently removes the co-auth-pending class only
on success (coFetch(...).then(() =>
document.documentElement.classList.remove('co-auth-pending'))), and swallows
errors in catch, leaving the class set on failures; update the promise handling
for coFetch to ensure
document.documentElement.classList.remove('co-auth-pending') runs on both
success and failure (use a .finally() or call the same remove in both .then and
.catch) and keep the catch logic for any error handling/logging as needed so the
class is always cleared.
In `@frontend/public/style/_layout.scss`:
- Around line 42-52: The reduced-motion media query currently only sets
animation-duration to 0s but leaves the 20s animation delay on
.co-page-skeleton__slow-msg, so update the `@media` (prefers-reduced-motion:
reduce) block to also cancel the delay (e.g., set animation: none or set
animation-delay: 0s in addition to animation-duration: 0s) for the
.co-page-skeleton__slow-msg selector to ensure the recovery hint appears
immediately for users who prefer reduced motion.
🪄 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: 692edb77-4ee9-4122-8703-6931a22e739e

📥 Commits

Reviewing files that changed from the base of the PR and between bfa581e and aecb812.

📒 Files selected for processing (12)
  • frontend/packages/console-app/src/components/detect-context/DetectContext.tsx
  • frontend/packages/console-shared/src/hooks/__tests__/useUser.spec.ts
  • frontend/packages/console-shared/src/hooks/useUser.ts
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/cloud-shell-utils.ts
  • frontend/public/actions/k8s.ts
  • frontend/public/components/app.tsx
  • frontend/public/components/cluster-settings/_cluster-settings.scss
  • frontend/public/index.html
  • frontend/public/locales/en/public.json
  • frontend/public/module/k8s/__tests__/swagger.spec.ts
  • frontend/public/module/k8s/swagger.ts
  • frontend/public/style/_layout.scss
✅ Files skipped from review due to trivial changes (3)
  • frontend/public/components/cluster-settings/_cluster-settings.scss
  • frontend/public/module/k8s/swagger.ts
  • frontend/packages/webterminal-plugin/src/components/cloud-shell/cloud-shell-utils.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • frontend/public/actions/k8s.ts
  • frontend/packages/console-shared/src/hooks/useUser.ts
  • frontend/public/module/k8s/tests/swagger.spec.ts
  • frontend/packages/console-shared/src/hooks/tests/useUser.spec.ts

Comment threadfrontend/public/components/app.tsx
Comment threadfrontend/public/style/_layout.scss
@logonoff
logonoffforce-pushed the OCPBUGS-86894-useuser branch from aecb812 to 632e26cCompareJune 5, 2026 02:00
logonoffand others added 2 commits June 8, 2026 15:25
- useUser: switch from useK8sGet to useK8sWatchResource so multiple
hook instances share a single watch instead of each fetching
users/~ independently (22 calls → 1)
- swagger: add fetch priority 'low' to openapi/v2 so the 3 MB
download yields to critical resources during startup
- app.tsx: add fetch priority 'high' to the early auth check
- cloud-shell-utils: add fetch priority 'low' to terminal/available
so it yields to critical startup resources
- actions/k8s: remove duplicate fetchSwagger call since app.tsx
already handles initial fetch and polling
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Also only render the skeleton if the user is confirmed to be able to access the k8s api. This way, PageSkeleton has no chance to load for unauthenticated users prior to the login page redirect
Also x2 extract the skip link into its own component so we can suspend it
@logonoff
logonoffforce-pushed the OCPBUGS-86894-useuser branch from 632e26c to 01d38eaCompareJune 8, 2026 19:35
@logonoff

Copy link
Copy Markdown
MemberAuthor

QA Verification Evidence

Details
BranchOCPBUGS-86894-useuser
Baselinemain @ 9459497c24
CandidateOCPBUGS-86894-useuser @ 01d38ea7a3
Verified2026-06-08
BrowserPlaywright 1.60.0 / Chrome for Testing 148.0.7778.96 (playwright chromium v1223)
OSDarwin 25.5.0
JiraOCPBUGS-86894

Verification Steps

#RouteActionStatus
numberrouteactionstatus
1/dashboardsNavigate, wait for loadpass
2/settings/clusterNavigate to cluster settingspass
3/k8s/cluster/nodesNavigate to nodes listpass
4/k8s/ns/openshift-console/podsNavigate to pods listpass
5/k8s/ns/openshift-console/deploymentsNavigate to deploymentspass
6(all pages)Check console errorspass
Animated overview (click to expand)
BaselineCandidate
Step 1: description (status)
Baseline (main)Candidate (OCPBUGS-86894-useuser)
Step 2: Dashboard overview (pass)
Baseline (main)Candidate (OCPBUGS-86894-useuser)
Step 3: Cluster settings page (SCSS change) (pass)
Baseline (main)Candidate (OCPBUGS-86894-useuser)
Step 4: Nodes list (user context) (pass)
Baseline (main)Candidate (OCPBUGS-86894-useuser)
Step 5: Pods in openshift-console (pass)
Baseline (main)Candidate (OCPBUGS-86894-useuser)

Warning

This verification was performed by an AI agent. Results may contain false positives or miss
regressions that require human judgment. Always review the screenshots manually before approving.

Automated QA verification by Claude Code

- Add beforeEach config reset to prevent state leaks between test
runs and retries. Relying solely on afterEach is fragile because
Alertmanager reloads config asynchronously from the patched secret.
- Increase save() timeout from 30s to 60s to accommodate slower
API responses in CI.
- Guard showAdvancedConfiguration() against double-toggling by
checking visibility before clicking, and add explicit timeout.
- Increase PagerDuty test timeout to 180s since it runs 12+ steps
with multiple navigations and API calls.
- showAdvancedConfiguration() clicks the toggle but returns before the section content renders, causing subsequent assertions on child elements to fail with "element(s) not found".
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@logonoff
logonoffforce-pushed the OCPBUGS-86894-useuser branch from 0061d6d to de4ed2fCompareJune 9, 2026 13:45
@logonoff

Copy link
Copy Markdown
MemberAuthor

/verified by @logonoff

@openshift-ci-robotopenshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jun 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@logonoff: This PR has been marked as verified by @logonoff.

Details

In response to this:

/verified by @logonoff

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

Copy link
Copy Markdown
Contributor

@logonoff: all tests passed!

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.

@Leo6Leo

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ciopenshift-ciBot added the lgtm Indicates that a PR is ready to be merged. label Jun 9, 2026
@openshift-merge-bot
openshift-merge-botBot merged commit d7aca4b into openshift:mainJun 9, 2026
9 checks passed
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@logonoff: Jira Issue Verification Checks: Jira Issue OCPBUGS-86894
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-86894 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

Details

In response to this:

Analysis / Root cause:

Profiling startup network activity revealed that the useUser hook (which fetches users/~ from the k8s API) uses useK8sGet — a hook with no cross-instance deduplication. Every component that calls useUser() (directly or via useTelemetry()) triggers an independent fetch. With ~10+ component instances mounting during startup, this produced 22 duplicate API calls to the same endpoint.

Additionally, the 3 MB openapi/v2 fetch and multiple terminal/available checks were competing with critical startup resources for bandwidth, with no fetch priority hints to let the browser schedule them appropriately.

Solution description:

  1. useUser: Switch from useK8sGet to useK8sWatchResource, which deduplicates at the Redux/watch infrastructure level. All hook instances share a single underlying watch, reducing users/~ calls from 22 to 1. This also correctly handles impersonation changes since the watch infrastructure reconnects when auth context changes.

  2. Fetch Priority hints (Fetch Priority API):

  • priority: 'high' on the early auth check (api/kubernetes/api) so the browser prioritizes the authentication redirect check
  • priority: 'low' on openapi/v2 (3 MB, used only for form field descriptions — not needed for initial render)
  • priority: 'low' on terminal/available checks (not render-critical)
  1. Remove duplicate fetchSwagger call from actions/k8s.tsapp.tsx already handles the initial fetch and 5-minute polling, so the second call 10 seconds after discovery was redundant.

Performance results

Tested under simulated Fast 3G (1.5 Mbps, 562ms RTT) + 4x CPU throttle, 5 runs each, browser cache cleared between runs. App-ready measured as time until [data-test="page-heading"] h1 is visible.

MetricBefore (main)After (this PR)Improvement
App ready (median)37.0s29.8s-7.1s (19% faster)
App ready (avg)36.2s29.2s-7.0s (19% faster)
Total API calls7347-26 calls (36% fewer)
Total resources loaded134107-27 resources (20% fewer)
users/~ calls221-21 calls
terminal/available calls83-5 calls
Total transfer2,974 KB2,933 KB-41 KB

Screenshots / screen recording:

Test setup:

Two console instances running against the same cluster:

  • :9000 — this PR (OCPBUGS-86894-useuser branch)
  • :9001 — HEAD of main

Both running over HTTP/1.1 with auth disabled, localhost bridge, same OCP 5.0 cluster.

Benchmarked with Playwright using Chrome DevTools Protocol for CPU/network throttling.

Test cases:

  • Verified users/~ is fetched exactly once during startup (was 22x)
  • Verified terminal/available uses priority: 'low' and yields to critical resources
  • Verified openapi/v2 uses priority: 'low' and downloads after critical resources
  • Verified impersonation still works correctly (useK8sWatchResource reconnects on auth change)
  • Verified the app renders the same UI with all features functional
  • Impersonation still works
  • yarn test passes

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:

The useK8sGet hook creates a new useState + useEffect per instance with no shared state — every component that mounts independently fetches the same resource. useK8sWatchResource uses the console's watch infrastructure which deduplicates at the Redux store level, so multiple hook instances share a single underlying fetch/watch.

The Fetch Priority API (priority: 'low' / 'high') is supported in Chrome 101+, Edge 101+, and Safari 17.2+. Unsupported browsers silently ignore the hint with no behavioral change.

Summary by CodeRabbit

  • Performance Improvements

  • Early auth API request is now prioritized; OpenAPI/Swagger fetches moved to low‑priority/background.

  • Updates

  • User data now syncs via a watch-based mechanism for more timely updates.

  • Terminal availability checks use lower‑priority network requests.

  • UI / UX

  • New auth‑pending skeleton, slow‑loading message with a refresh action, updated loading fallback, and two new English strings.

  • Tests

  • Updated tests to reflect watch-based user loading and related behaviors.

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

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Leo6Leo, logonoff, vojtechszocs

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

@logonoff
logonoff deleted the OCPBUGS-86894-useuser branch June 9, 2026 19:57
@openshift-merge-robot

Copy link
Copy Markdown
Contributor

Fix included in release 5.0.0-0.nightly-2026-06-10-003138

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

Labels

approvedIndicates a PR has been approved by an approver from all required OWNERS files.component/coreRelated to console core functionalitycomponent/sharedRelated to console-sharedjira/valid-bugIndicates that a referenced Jira bug is valid for the branch this PR is targeting.jira/valid-referenceIndicates that this PR references a valid Jira ticket of any type.kind/i18nIndicates issue or PR relates to internationalization or has content that needs to be translatedlgtmIndicates that a PR is ready to be merged.verifiedSignifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@logonoff@openshift-ci-robot@Leo6Leo@openshift-merge-robot@vojtechszocs