Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Apply smart refetchInterval to all resource tables #7216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

lovincyrus
Copy link
Contributor

@lovincyrus lovincyrus commented Apr 24, 2025

Closes #6667

In this pull request, we introduced a custom refetch interval to repeatedly reload a resource until its status was marked as complete. That same custom refetch interval is being applied to dashboards, alerts, and reports.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@lovincyrus lovincyrus self-assigned this Apr 24, 2025
@lovincyrus lovincyrus marked this pull request as ready for review April 28, 2025 15:55
@lovincyrus lovincyrus changed the title Enable refetchIntervalInBackground to all resource tables Enable refetchIntervalInBackground to all resource tables Apr 28, 2025
Copy link
Contributor

@ericpgreen2 ericpgreen2 left a comment

Choose a reason for hiding this comment

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

However, for dashboards, reports, and alerts tables, this approach isn't required

For dashboards especially, we would like to poll the ListResources API when the resource has not finished reconciling. This will particularly help the UX when deploying projects (see my comment in the setup.ts file).

Copy link
Contributor

@ericpgreen2 ericpgreen2 left a comment

Choose a reason for hiding this comment

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

Rather than repeating the refetch function across each resource file, can we put it in one central location? Maybe features/projects would be the right directory?

@ericpgreen2
Copy link
Contributor

Additionally, mind updating the PR description?

@ericpgreen2 ericpgreen2 changed the title Enable refetchIntervalInBackground to all resource tables Apply smart refetchInterval to all resource tables May 1, 2025
Copy link
Contributor

@ericpgreen2 ericpgreen2 left a comment

Choose a reason for hiding this comment

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

When I refetch a resource on the Project Status page, I see double network requests: one with skipSecurityChecks, one without. I'm expecting that only the skipSecurityChecks one would be refetched.
image

Comment on lines 30 to 42
refetchInterval: (query) => {
const newInterval = calculateRefetchInterval(
currentRefetchInterval,
query.state.data,
query,
);
if (newInterval === false) {
currentRefetchInterval = INITIAL_REFETCH_INTERVAL;
return false;
}
currentRefetchInterval = newInterval;
return newInterval;
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Tracking state outside of the calculateRefetchInterval function makes this more complex than it feels like it should be. I'm wondering if there's a way calculateRefetchInterval could encompass all of the logic, so we could call it like this:

query: {
    ...
    refetchInterval: calculateRefetchInterval // more descriptive name could be something like `pollUntilResourcesReconciled`
}

One idea, could we add custom state to either query.meta or query.state, e.g. query.state.currentRefetchInterval = X?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed that we should keep the refetchInterval state encapsulated within the component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cloud UI: apply refetchInterval function to all resource tables
3 participants