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 49 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

@lovincyrus lovincyrus changed the title Apply smart refetchInterval to all resource tables [ENG-70] Apply smart refetchInterval to all resource tables May 12, 2025
@lovincyrus lovincyrus changed the title [ENG-70] Apply smart refetchInterval to all resource tables [APP-56] Apply smart refetchInterval to all resource tables May 13, 2025
@lovincyrus lovincyrus force-pushed the cyrus/refetch-interval-all-resource-tables branch from 0bc973f to c00c0a6 Compare June 9, 2025 23:33
@lovincyrus lovincyrus force-pushed the cyrus/refetch-interval-all-resource-tables branch from 7c10177 to 6671e12 Compare June 12, 2025 05:19
@lovincyrus lovincyrus requested a review from ericpgreen2 June 12, 2025 05:54
Comment on lines 24 to 28
select: (data) => {
updateSmartRefetchInterval(data?.resources);
return data;
},
refetchInterval: () => get(refetchInterval),
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be better if the refetch interval logic were all encapsulated in the refetchInterval parameter. It's not very clean to add (half of) the refetch logic as a side effect to the select function.

Comment on lines 9 to 12
// Store for the current refetch interval
export const refetchInterval = writable<number | false>(
INITIAL_REFETCH_INTERVAL,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think one global store will work. This prohibits us from having two queries on the same page that use the smart refetch logic. For example, both the ProjectGlobalStatusIndicator and e.g. the DashboardsTable components are mounted at the same time and should use the smart refetch logic for their respective queries.

Can you please try the query.meta approach?

Per the docs, the meta field is intended for user-defined state. Yes, it's usually static state, but dynamic state might still work.
image

@lovincyrus lovincyrus changed the title [APP-56] Apply smart refetchInterval to all resource tables Apply smart refetchInterval to all resource tables Jun 18, 2025
@nishantmonu51
Copy link
Collaborator

@lovincyrus : Any updates on this PR ? Whats next here?

@lovincyrus lovincyrus requested a review from nishantmonu51 July 4, 2025 16:33
@ericpgreen2
Copy link
Contributor

@lovincyrus, checking in on this PR, have you given any thought to these two comments?

image

@lovincyrus
Copy link
Contributor Author

@lovincyrus, checking in on this PR, have you given any thought to these two comments?

image

Ah, I responded in another thread #7216 (comment) We can certainly reconsider them

@lovincyrus
Copy link
Contributor Author

@lovincyrus : Any updates on this PR ? Whats next here?

I plan to revisit this after completing the data connector UX sprints.

@lovincyrus lovincyrus force-pushed the cyrus/refetch-interval-all-resource-tables branch from 1859503 to 029759c Compare July 30, 2025 16:45
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
4 participants