Skip to content

fix(infra-monitoring): request loop when click to visualize volume#10657

Open
H4ad wants to merge 1 commit intomainfrom
fix/infra-monitoring-volume-loop
Open

fix(infra-monitoring): request loop when click to visualize volume#10657
H4ad wants to merge 1 commit intomainfrom
fix/infra-monitoring-volume-loop

Conversation

@H4ad
Copy link
Contributor

@H4ad H4ad commented Mar 19, 2026

Pull Request

This PR fixes the loop bug on select volumes caused by the min/max time being updates being included in the query to fetch data for the volume details charts.


📄 Summary

Why does this change exist?
What problem does it solve, and why is this the right approach?

This PR fixes the bug by not adding the min/max time into the query keys.

Screenshots / Screen Recordings (if applicable)

Include screenshots or screen recordings that clearly show the behavior before the change and the result after the change. This helps reviewers quickly understand the impact and verify the update.

Before:

screenrecording-2026-03-19_12-08-02.mp4

After:

screenrecording-2026-03-19_12-07-25.mp4

Issues closed by this PR

Reference issues using Closes #issue-number to enable automatic closure on merge.

Closes #8677


✅ Change Type

Select all that apply

  • ✨ Feature
  • 🐛 Bug fix
  • ♻️ Refactor
  • 🛠️ Infra / Tooling
  • 🧪 Test-only

🐛 Bug Context

Required if this PR fixes a bug

The bug caused the page to enter in a loop of refetching the queries to get the volume data.

Root Cause

What caused the issue?
Regression, faulty assumption, edge case, refactor, etc.

This was caused by min/max being updated for some reason after the queries for chart run.

Fix Strategy

How does this PR address the root cause?

Remove min/max from the query key.


🧪 Testing Strategy

How was this change validated?

  • Tests added/updated: Yes
  • Manual verification: Yes

📝 Changelog

Fill only if this affects users, APIs, UI, or documented behavior
Use N/A for internal or non-user-facing changes

Field Value
Deployment Type Cloud / OSS / Enterprise
Change Type Bug Fix
Description Fixed the loop bug when opening volumes inside Infrastructure Monitoring

📋 Checklist

  • Tests added or explicitly not required
  • Manually tested
  • Breaking changes documented
  • Backward compatibility considered

@H4ad H4ad requested a review from Copilot March 19, 2026 15:17
@H4ad H4ad requested a review from a team as a code owner March 19, 2026 15:17
@github-actions github-actions bot added the bug Something isn't working label Mar 19, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an infinite refetch loop in Infrastructure Monitoring’s Kubernetes Volumes detail flow by adjusting how react-query cache keys are generated so time-range updates don’t continuously invalidate the volumes list query when a volume is selected.

Changes:

  • Introduces custom query-key builders for the volumes list and grouped-row fetches to exclude minTime/maxTime when a volume is selected.
  • Updates K8sVolumesList to use the new query keys for useGetK8sVolumesList.
  • Adds a Volumes list test suite, including a regression test asserting no list refetch after time-range changes when a volume is selected.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
frontend/src/container/InfraMonitoringK8s/__tests__/Volumes/K8sVolumesList.test.tsx Adds regression coverage for the volumes click/detail flow and the refetch-loop scenario.
frontend/src/container/InfraMonitoringK8s/Volumes/utils.tsx Adds helper functions to generate react-query keys for volumes list and grouped-row fetches.
frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.tsx Switches volumes queries to use the new query-key helpers (intended to prevent infinite refetching).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@H4ad H4ad requested review from AshwinBhatkal and ahrefabhi March 19, 2026 16:23
@H4ad H4ad force-pushed the fix/infra-monitoring-volume-loop branch from 7d8d198 to ca6a00e Compare March 19, 2026 16:29
@H4ad H4ad requested a review from Copilot March 19, 2026 16:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to stop an infinite refetch loop on the Infra Monitoring Kubernetes Volumes page by adjusting the react-query cache keys so that minTime/maxTime changes don’t trigger list refetches while a volume detail is open.

Changes:

  • Introduces helper functions to generate stable react-query keys for volumes list and grouped-row fetches.
  • Updates K8sVolumesList to use the new query keys instead of keying on the entire request payload.
  • Adds a new test suite for K8sVolumesList, including a regression test for the “no refetch on time change after selecting a volume” behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
frontend/src/container/InfraMonitoringK8s/Volumes/utils.tsx Adds query-key builder helpers intended to omit min/max time when a volume is selected.
frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.tsx Switches list and grouped-row queries to use the new query keys.
frontend/src/container/InfraMonitoringK8s/__tests__/Volumes/K8sVolumesList.test.tsx Adds tests for rendering, opening/closing details, and preventing list refetch on time change after selection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +81 to +107
export const getVolumeListGroupedByRowDataQueryKey = (
groupedByMeta: K8sVolumesData['meta'] | undefined,
queryFilters: IBuilderQuery['filters'],
orderBy: { columnName: string; order: 'asc' | 'desc' } | null,
groupBy: IBuilderQuery['groupBy'],
minTime: number,
maxTime: number,
): (string | undefined)[] => {
const selectedRowDataKey = JSON.stringify(groupedByMeta || undefined);
if (groupedByMeta) {
return [
'volumeList',
JSON.stringify(queryFilters),
JSON.stringify(orderBy),
JSON.stringify(groupBy),
selectedRowDataKey,
];
}
return [
'volumeList',
JSON.stringify(queryFilters),
JSON.stringify(orderBy),
JSON.stringify(groupBy),
selectedRowDataKey,
String(minTime),
String(maxTime),
];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This causes loop error.

Comment on lines +207 to +210
// Allow any potential re-fetch to settle
await new Promise((resolve) => {
setTimeout(resolve, 300);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does not helps catch the regression or the bug if we introduce the same bug again.

@H4ad H4ad force-pushed the fix/infra-monitoring-volume-loop branch from 6f1e16a to 6483c1b Compare March 19, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working infra-monitoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Infrastructure > Volumes - PVC detail page causes infinite reload loop when clicked

2 participants