Skip to content

OU-1315: reset queries when namespace changes in dev perspective#932

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
PeterYurkovich:ou-1315
May 12, 2026
Merged

OU-1315: reset queries when namespace changes in dev perspective#932
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
PeterYurkovich:ou-1315

Conversation

@PeterYurkovich
Copy link
Copy Markdown
Contributor

@PeterYurkovich PeterYurkovich commented May 12, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved metric query handling when switching monitoring namespaces to prevent unnecessary clearing in non-developer views while ensuring queries reset appropriately in developer mode.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 12, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 12, 2026

@PeterYurkovich: This pull request references OU-1315 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

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 openshift-ci Bot requested review from etmurasaki and zhuje May 12, 2026 13:34
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 12, 2026
@zhuje
Copy link
Copy Markdown
Contributor

zhuje commented May 12, 2026

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 12, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: PeterYurkovich, zhuje

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:
  • OWNERS [PeterYurkovich,zhuje]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Walkthrough

The PR updates MetricsPage to track namespace changes using useRef and adds an effect that clears all metric queries when the namespace changes, but only when the namespace selector is hidden (non-developer view mode).

Changes

Namespace Change Detection with Conditional Query Clearing

Layer / File(s) Summary
Hook imports and namespace tracking
web/src/components/MetricsPage.tsx (line 65, 1341)
React imports now include useRef. MetricsPage_ destructures both namespace and setNamespace from useMonitoringNamespace to enable change detection.
Query clearing effect
web/src/components/MetricsPage.tsx (lines 1406–1416)
Effect using prevNamespace ref compares current namespace against previous value and calls dispatch(queryBrowserDeleteAllQueries()) only when namespace changes and displayNamespaceSelector is false, preventing unnecessary query clearing during namespace selections in developer view.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Test Structure And Quality ❓ Inconclusive Custom check expects Ginkgo test patterns, but PR contains standard Go tests using testing.T package, not Ginkgo. Check is inapplicable. The PR's test file uses standard Go testing, not Ginkgo (no It blocks, BeforeEach/AfterEach, Eventually/Consistently patterns found).
✅ 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: resetting queries when namespace changes in the developer perspective, which matches the primary objective and code modifications.
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 No Ginkgo tests present in the PR. The codebase uses standard Go testing only, with no Ginkgo imports or test constructs. Check is not applicable.
Microshift Test Compatibility ✅ Passed This PR only modifies a React component (MetricsPage.tsx) and does not add Ginkgo e2e tests. The MicroShift Test Compatibility check applies only to e2e test additions.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No Ginkgo e2e tests added in this PR. Only Cypress tests and standard Go unit tests present. Check not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies UI component and adds deployment without scheduling constraints. No affinity, nodeSelector, tolerations, or PDB issues. Replica count 2 is topology-appropriate.
Ote Binary Stdout Contract ✅ Passed OTE check applies to Go binaries. PR modifies only TypeScript/React frontend (web/src/components/MetricsPage.tsx), not Go binaries. Check not applicable to frontend code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Custom check targets Ginkgo e2e tests for IPv6/disconnected compatibility. This PR modifies only React/TypeScript components and does not add any Ginkgo e2e tests. Check is not applicable.

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

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

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.

🧹 Nitpick comments (1)
web/src/components/MetricsPage.tsx (1)

1407-1415: ⚡ Quick win

Fix useEffect dependencies in namespace-reset logic.

The effect at line 1407 reads displayNamespaceSelector on line 1410 but it's missing from the dependency array [namespace, dispatch, setNamespace]. Meanwhile, setNamespace is in the array but never used in the effect body. This creates a stale closure risk if displayNamespaceSelector changes during component lifetime. Also reset prevNamespace.current when the selector becomes visible to keep the baseline in sync.

Proposed patch
   const prevNamespace = useRef(namespace);
   useEffect(() => {
     // In the developer perspective (display namespace selector is false since all dev perspective
     // pages add them automatically) then clear queries when the namespace changes
-    if (prevNamespace.current === namespace || displayNamespaceSelector) {
+    if (displayNamespaceSelector) {
+      prevNamespace.current = namespace;
+      return;
+    }
+    if (prevNamespace.current === namespace) {
       return;
     }
     prevNamespace.current = namespace;
     dispatch(queryBrowserDeleteAllQueries());
-  }, [namespace, dispatch, setNamespace]);
+  }, [namespace, displayNamespaceSelector, dispatch]);
🤖 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 `@web/src/components/MetricsPage.tsx` around lines 1407 - 1415, The effect uses
displayNamespaceSelector but doesn't include it in the dependency array and
includes setNamespace which is unused; update the useEffect that references
prevNamespace, namespace, displayNamespaceSelector, dispatch and
queryBrowserDeleteAllQueries to: add displayNamespaceSelector to the dependency
array, remove setNamespace from the dependencies, and inside the effect when
displayNamespaceSelector becomes true reset prevNamespace.current (e.g. to
undefined/null) so the baseline is in sync; keep the existing logic that
compares prevNamespace.current to namespace and dispatches
queryBrowserDeleteAllQueries() when it changes.
🤖 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 `@web/src/components/MetricsPage.tsx`:
- Around line 1407-1415: The effect uses displayNamespaceSelector but doesn't
include it in the dependency array and includes setNamespace which is unused;
update the useEffect that references prevNamespace, namespace,
displayNamespaceSelector, dispatch and queryBrowserDeleteAllQueries to: add
displayNamespaceSelector to the dependency array, remove setNamespace from the
dependencies, and inside the effect when displayNamespaceSelector becomes true
reset prevNamespace.current (e.g. to undefined/null) so the baseline is in sync;
keep the existing logic that compares prevNamespace.current to namespace and
dispatches queryBrowserDeleteAllQueries() when it changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: fc403dce-50b0-4f64-988c-9c4c1cffcd0f

📥 Commits

Reviewing files that changed from the base of the PR and between 3d4bd16 and 8816d4f.

📒 Files selected for processing (1)
  • web/src/components/MetricsPage.tsx

@etmurasaki
Copy link
Copy Markdown
Contributor

/label qe-approved

@openshift-ci openshift-ci Bot added the qe-approved Signifies that QE has signed off on this PR label May 12, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 12, 2026

@PeterYurkovich: This pull request references OU-1315 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target either version "5.0." or "openshift-5.0.", but it targets "openshift-4.22" instead.

Details

In response to this:

Summary by CodeRabbit

  • Bug Fixes
  • Improved metric query handling when switching monitoring namespaces to prevent unnecessary clearing in non-developer views while ensuring queries reset appropriately in developer mode.

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.

@PeterYurkovich
Copy link
Copy Markdown
Contributor Author

/cherry-pick release-4.22

@openshift-cherrypick-robot
Copy link
Copy Markdown

@PeterYurkovich: once the present PR merges, I will cherry-pick it on top of release-4.22 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-4.22

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-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

@PeterYurkovich: 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.

@openshift-merge-bot openshift-merge-bot Bot merged commit 0070343 into openshift:main May 12, 2026
10 checks passed
@openshift-cherrypick-robot
Copy link
Copy Markdown

@PeterYurkovich: new pull request created: #934

Details

In response to this:

/cherry-pick release-4.22

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants