Skip to content
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

Add server-side pagination to home page cluster list #11663

Merged
merged 26 commits into from
Jan 3, 2025

Conversation

richard-cox
Copy link
Member

@richard-cox richard-cox commented Aug 19, 2024

Blocked on

Is Impacted by

Summary

Fixes #10283

Occurred changes and/or fixed issues

Server-side pagination for home page clusters list and side bar clusters

  • Functional Changes
    • SSP now works after vue3 bump
    • Home Page Clusters list now uses server-side pagination
    • Side Bar clusters list now uses server-side pagination
    • Wire in now supported sorting / filtering by id and name used for table columns
    • Allow pagination to be enabled given a specific context
    • Call findPage without persisting to store
    • Fixed filtering by project/namespace
  • New Pagination Tools
    • PaginatedResourceTable - Convenience Component, wraps ResourceTable with pagination specific props
    • PaginationWrapper - Convenience class to handle requests for resources and updates to them (avoiding store)
  • Regressions
    • Side Nav menu ready state was mgmtCluster.isReady && !pCluster?.hasError, will be status.conditions[0].status (blocked on SQLite backed cache: Support sorting mgmt clusters on value in a specific condition rancher#48092)
    • Home Page / Cluster
      • (Generic) state search / filter is now only on resource metadata.state.name, not our fancy models version
      • Home Page Cluster List
        • name - shows prov cluster name (instead of mgmt nameDisplay)
        • provider is now not sortable/filterable (given this is data from mgmt cluster)
        • CPU - is now not sortable/filterable (comes from mgmt cluster)
        • Memory - is now not sortable/filterable (comes from mgmt cluster)
        • Pods - is now not sortable/filterable (comes from mgmt cluster)

Areas or cases that should be tested

  • All aspects of cluster list in side bar
  • All aspects of home page cluster list

Areas which could experience regressions

  • all lists with pagination on / off
  • application of the hide-local-cluster setting

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
    • Testing will be done manually later on
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes

- Functional Changes
  - SSP now works after vue3 bump
  - Home Page Clusters list now uses server-side pagination
  - Side Bar clusters list now uses server-side pagination
  - Wire in now supported sorting / filtering by id and name used for table columns
  - Allow pagination to be enabled given a specific context
  - Call findPage without persisting to store

- New Pagination Tools
  - PaginatedResourceTable - Convenience Component, wraps ResourceTable with pagination specific props
  - PaginationWrapper - Convenience class to handle requests for resources and updates to them (avoiding store)

- Regressions
  - Side Nav menu ready state was `mgmtCluster.isReady && !pCluster?.hasError`, now ???
@richard-cox richard-cox force-pushed the pagination-home-page branch 2 times, most recently from 42b3845 to 6d14429 Compare December 2, 2024 17:31
Note - prov clusters is broken (only fetches local) due to blocking pr. breals
- notPinned list
- remove from resource list, put in resource-fetch (used also by pag res table)
- changes namespaces kicked of side nav cluster requests (thought pinnedIds changed)
- fix generic lists re-fetching given ns filter changes (they don't have namespaced arg)
@richard-cox richard-cox removed the ci/skip-e2e Forcibly skip E2E tests in the CI label Dec 5, 2024
codyrancher
codyrancher previously approved these changes Dec 6, 2024
Copy link
Contributor

@codyrancher codyrancher left a comment

Choose a reason for hiding this comment

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

I don't think any of my comments warrant blocking this from merging. After the gates pass I say go for it.

it should be fine to improve these issues after this is merged.

shell/components/PaginatedResourceTable.vue Outdated Show resolved Hide resolved
shell/components/SortableTable/index.vue Show resolved Hide resolved
shell/utils/cluster.js Outdated Show resolved Hide resolved
Comment on lines 124 to +126
await this.$fetch();
if (this.canPaginate && this.fetchPageSecondaryResources) {
this.fetchPageSecondaryResources(true);
this.fetchPageSecondaryResources({
Copy link
Contributor

Choose a reason for hiding this comment

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

This is another place where we may want to initiate the requests in parallel.

By any chance do we also want to await the secondary resource here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately we can't on this one. $fetch will make the http request to get the page which is then used by fetchPageSecondaryResources to get resources dependent on it's response.

I think fetchSecondaryResources, fetchPageSecondaryResources and the content of this function might be tweaked in future depending on how we react to the new resources.changed event.

  • root resource type changes - We would need to refetch the current page (basically do exactly the same as this function - fetch page, fetch resources dependent on page).
  • secondary resource type changes - (fetched via fetchSecondaryResources, are general resources not page dependent). We would need to refetch whole secondry resource set
  • resource dependent on page - We would need to call fetchPageSecondaryResources

id: CAPI.RANCHER_CLUSTER,
context: 'side-bar',
});
const helper = canPagination ? new TopLevelMenuHelperPagination({ $store: this.$store }) : new TopLevelMenuHelperLegacy({ $store: this.$store });
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR but I have a feeling we're going to want to make these helpers more generic and perhaps add the updating/debouncing to the thelpers

Copy link
Member Author

Choose a reason for hiding this comment

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

That's my plan for the PaginationWrappers (very open to renaming, maybe PaginationHandler?). Those should be able to receive some pagination settings, return the page and also notify when that page has changed. It's a new util though so not wired in everywhere

Comment on lines +263 to +273
management: {
resources: {
enableAll: false,
enableSome: {
enabled: [
{ resource: CAPI.RANCHER_CLUSTER, context: ['home', 'side-bar'] },
{ resource: MANAGEMENT.CLUSTER, context: ['side-bar'] },
],
generic: false,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we splitting SSP up into different user settings?

To me it seems like we should really just make SSP an all or nothing setting.

Copy link
Member Author

@richard-cox richard-cox Dec 9, 2024

Choose a reason for hiding this comment

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

This was important for the gradual conversion to SSP, possibly still so given enabling in a global way might start breaking things (including e2e).

It's all store based. lists (and any SSP request) will be enabled either by

  • all
  • some
    • specific resources
    • generic (lists without any list component or custom headers)

At the end of 2.11 dev cycle in theory we'll just be left with all for cluster and management stores but not if there's some weird lists in crevices that we didn't reach

// Normally owner components supply `resource` and `inStore` as part of their data, however these are needed here before parent data runs
// So set up both here
const params = { ...this.$route.params };
const resource = params.resource || this.schema?.id; // Resource can either be on a page showing single list, or a page of a resource showing a list of another resource
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this for instances like being on a Node detail page and we're listing pods? If so, can we just make a pods list component and just use this on the components that are going to list paginated resources and not have to differentiate between list/detail page in a mixin like this?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for showing the clusters in the home page (no resource in route) and resolves a frustrating issue were child mixins and components data resolve before parent data.

The pods list in node detail view is a vanilla ResourceTable working on a node model property which applies a filter to all Pods in store, however the node detail page populates pods in store with only those associated with the node.

in the future we should switch the pods list in node detail to use the new PaginatedResourceTable (which would be supplied with a special filter to get only those from a node). Noticed we'd hit a bug then where the pod list would look at the node from params instead, will need to re-think this approach at that point

shell/plugins/dashboard-store/actions.js Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only real concern I have in this PR. The amount of changes we had to do here makes me a little concerned about the abstractions/interfaces that we're relying on. I guess it's mostly a problem with pinning and searching though.

Copy link
Member Author

@richard-cox richard-cox Dec 9, 2024

Choose a reason for hiding this comment

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

I pushed a lot of the 'fetch x' style functionality into the legacy top level helper and made the interface layer such that the require data could also be returned via SSP requests.

The component is generally hard to understand as there's so much weirdness. pinned (split's cluster list into two pinned / not pinned), search (pinned list is not shown, not pinned list becomes search result which may show pinned clusters), local cluster (always appears at top of either pinned or not-pinned/filtered clusters). There's definitely a opportunity to improve this once we're sure the old way is no longer needed and the helpers ssp helper can be folded into the component and legacy helper dropped

@richard-cox
Copy link
Member Author

richard-cox commented Dec 10, 2024

@codyrancher comments addressed and e2e tests are now passing. just waiting on rancher/rancher#48349 to merge before resolving the remaining TODOs

Update:

  • I've bee resolving the remaining TODOs, including testing with genuine clusters. That's exposed a number of bugs, most tackled, still some to test. More detail in the last commit, but the big one is now we won't fetch all mgmt clusters on dashboard load. Needed to happen at some point, was hoping later on though.
  • There's a blocking issue that prevents our vai e2e tests running (external - [BUG] SQLite backed cache: services cache fails to be created, blocking other resources  rancher#48384), that should be resolved and our vai e2e tests passing again before we can get this in

- general fixes
- correct issue were sorting prov clusters on mgmt cluster props (issue in master as well...)
- bit the bullet, we now don't fetch all mgmt clusters on dashboard visit.
  - there could be knock on affects, but we'd need to remove it sometime in 2.11....
@codyrancher codyrancher self-requested a review December 12, 2024 15:42
codyrancher
codyrancher previously approved these changes Dec 12, 2024
Copy link
Contributor

@codyrancher codyrancher left a comment

Choose a reason for hiding this comment

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

I'm happy to have it merged once the tests pass as you've already mentioned.

@richard-cox
Copy link
Member Author

All TODOs resoled. There are some outstanding parts split out to new issues (see descriptions linked in issue).

Only really remaining blocker is the disabled vai tests (not caused by PR, but PR brings in vai related changes).

@richard-cox richard-cox marked this pull request as ready for review January 3, 2025 10:26
@richard-cox richard-cox merged commit b614082 into rancher:master Jan 3, 2025
32 checks passed
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.

Performance: Server-side pagination: home page cluster list
3 participants