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 cluster explorer lists #11672

Merged
merged 73 commits into from
Jan 7, 2025

Conversation

richard-cox
Copy link
Member

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

Blocked on

No Longer Blocked on

Impacted by

Outstanding (separate PR)

Working around rancher/rancher#40773

Summary

Fixes #9546
Fixes #12555

Occurred changes and/or fixed issues

  • Functional Changes
    • service list service type now shows Cluster IP (Headless) instead of just Headless (makes sort possible in SSP world, and is a better general value)
    • not quite functional but console warnings made when a request to filter/sort on an unsupported field are now only made in dev mode
    • not quite functional but the automated tests that construct an extension and run it against a shell made from the current branch now use list/namespace.vue instead of the now TS file list/catalog.cattle.io.clusterrepo.vue. The later has TS build errors
  • New Pagination Tools
    • Pagination settings page now had a 'reset to default' option. This helps in short term whilst settings are in flux
  • Regressions
    • NOTE - This contains items that were not tracked from previous PRs (mainly secret, configmap, node)
    • workload health (sum of pod states) and pod restart count columns have been removed for all workload types
      • We should be able to bring these back when we get label selectors (and making a request per row to fetch specific pods given label selector)
    • job
    • pod restarts has been removed for all workloads
      • this is the sum of restarts for pods
    • persistentvolume
      • pv source is now not sortable/filterable (uses local smarts)
    • configmap
      • keys is now not sortable/filterable (uses local smarts)
    • secret
      • secret data is now not sortable/filterable (uses local smarts)
    • networking.k8s.io.ingress
      • default backend is now not sortable/filterable (uses local smarts)
    • pod
      • images is now not sortable (sorting on an array)
    • node
      • role - is now not sortable/filterable (uses local smarts)
      • internal ip - is now not sortable/filterable (uses local smarts)
      • cpu - is now not sortable/filterable (uses local calculation)
      • ram - is now not sortable/filterable (uses local calculation)
    • catalog.cattle.io.app
      • chart is now only sorted/filtered on name (and not version as well) TODO split into two columns?
      • chart upgrade is not now sortable/filterable (uses smarts locally to determine if one is available)
    • catalog.cattle.io.clusterrepo
      • type - is now not sortable/filterable (uses local smarts git vs oci vs http)
      • url - is now not sortable/filterable (uses local smarts)
  • Converted Lists
    • Cluster dashboard / events list
    • Cluster / Events
    • Cluster / Node (now uses PaginatedResourceTable)
    • Workloads
      • All (minus previously done pods)
    • Apps / Installed Apps
    • Apps / Repositories
    • Apps / Recent Operations
    • Service Discovery / HPA
    • Service Discovery / Ingresses
    • Service Discovery / Services
    • Storage / PersistentVolumes
    • Storage / StorageClasses
    • Storage / PersistentVolumeClaims
  • Fixes
    • Fix issue where list components containing PaginatedResourceTables would incorrectly fetch all resources anyway
    • Fix async button icon alignment when in manual refresh mode
    • Ensure PaginatedTableResources pass through correct props
      • use-query-params-for-simple-filtering prop comes from resource list (so needs to pass through from generic resource list component --> actual resource list component --> paginated resource table component)
      • force-update-live-and-delayed prop comes from mixins (so only needs to pass through in scenarios where the component as a mixin with it in)
    • sortable table had a bug from vue3 migration ( showHeaderRow just needs to know slots exist, rather than creating components)

Technical notes summary

Areas or cases that should be tested

  • As per converted lists

Areas which could experience regressions

  • As per converted lists

Screenshot/Video

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
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes

@richard-cox richard-cox added this to the v2.10.0 milestone Aug 20, 2024
@richard-cox richard-cox self-assigned this Aug 20, 2024
@richard-cox richard-cox changed the title Add server-side pagination to cluster explorer events and general events list Add server-side pagination to cluster explorer lists Aug 23, 2024
@nwmac
Copy link
Member

nwmac commented Oct 25, 2024

@richard-cox Is this for 2.10?

- 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 added the ci/skip-e2e Forcibly skip E2E tests in the CI label Nov 14, 2024
…would incorrectly fetch all resources anyway

- convert reminaing storage lists
@richard-cox richard-cox force-pushed the pagination-cluster-explorer branch from 840f93f to 006debb Compare November 15, 2024 16:38
- 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 ???
- caused by shell/scripts/test-plugins-build.sh importing list/catalog.cattle.io.clusterrepo.vue
- the component had been updated to a TS component
- check-plugin build outputs TS errors for a component file imports
- vs code shows no errors for imported file
Comment on lines -270 to -271
cy.get('@consoleError').should('not.be.called'); // See error lot
cy.get('@consoleWarn').should('not.be.called'); // See warning log (there will be some....)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this go back in? Are we avoiding warnings and errors or is it just not necessary anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines 71 to 74
// If the custom component contains the paginated resource table it'll control the fetching
if (component?.components?.['PaginatedResourceTable']) {
this.componentWillFetch = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this resolving? This looks like a gotcha waiting to happen, I also don't like how we're adding more implicit logic which will cause more effort when we try to de-tangle and make things more composable.

Copy link
Member Author

Choose a reason for hiding this comment

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

The ResourceList component will either

  • fetch the resources and display them in a list
  • not fetch the resources and let the custom list component do it all (fetch and display)

For the second point the ResourceList then needs to know if it should not fetch the resources. It already does this if the custom list component contains a fetch method (then sets componentWillFetch = true). This change does the same but if the custom list component contains a PaginatedResourceTable component.

I've combined this logic to be neater and clearer.

In the future the fetch method one will go away and we should then i guess do something neater than checking if the custom list has a specific component

Comment on lines +264 to +271
enabled: [
NODE, EVENT,
WORKLOAD_TYPES.CRON_JOB, WORKLOAD_TYPES.DAEMON_SET, WORKLOAD_TYPES.DEPLOYMENT, WORKLOAD_TYPES.JOB, WORKLOAD_TYPES.STATEFUL_SET, POD,
CATALOG.APP, CATALOG.CLUSTER_REPO, CATALOG.OPERATION,
HPA, INGRESS, SERVICE,
PV, CONFIG_MAP, STORAGE_CLASS, PVC, SECRET,
WORKLOAD_TYPES.REPLICA_SET, WORKLOAD_TYPES.REPLICATION_CONTROLLER
],
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there anything on the backend roadmap to enable caching for all resources? It seems like pagination is going to have limited use for extensions and apps if we have to enable each one separately.

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 and the resource updates were the two mahoosive discussion points when they designed the solution.

Unfortunately anything that is sorted/filtered does so on a db indexed field and matching go code... so needs to be known up front. Think the code part was why just a sql alter table can't be used.

It was agreed they would (promptly) manually add them at dev time for us.

For extensions we agreed that extension owners that work with CRDs should ensure they contain additional printer columns. Those will be returned in the rancher schema as attributes.columns (which the dashboard will show as columns in lists) which reference the resources metadata.fields array. The metadata.fields array is indexed, so lists will automatically enable sort/filter on them.

deployments atttributes.columns

{
"name": "Containers",
"type": "string",
"format": "",
"description": "Names of each container in the template.",
"priority": 1,
"field": "$.metadata.fields[5]"
},

deployment metadata.fields

[ 
...,
...,
...,
...,
...,
"fleet-controller,fleet-cleanup,fleet-agentmanagement",
...,
...,
],

Extension developers though that wish to sort/filter on resources where they don't own the CRD ... are blocked. We would need to come back with real use cases for that one

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.

Overall simple changes. I think once the todos and the tests pass we'll be fine to merge.

- Remove final todo's
  - includes fix for service type clusterip/headless overlap
- Removed ununused ENDPOINT column (note ENDPOINT formatter used in other columns)
- Testing freshly added index fields
@@ -320,15 +326,6 @@ export const POD_RESTARTS = {
liveUpdates: true
};

export const ENDPOINTS = {
Copy link
Member Author

Choose a reason for hiding this comment

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

Not used (though other columns will use the Endpoints formatter)

@richard-cox richard-cox marked this pull request as ready for review January 6, 2025 16:15
@codyrancher codyrancher self-requested a review January 6, 2025 22:30
codyrancher
codyrancher previously approved these changes Jan 6, 2025
@richard-cox richard-cox force-pushed the pagination-cluster-explorer branch 2 times, most recently from 7acff6b to 745ec3b Compare January 7, 2025 14:34
@richard-cox richard-cox force-pushed the pagination-cluster-explorer branch 2 times, most recently from df685b0 to a17f1d9 Compare January 7, 2025 16:58
- fix cluster dashboard events test
- fix and greatly improve flaky events test
- fix hpa test
- functional fixes
  - fix sorting/filtering events by object type
  - fix hpa columns
@richard-cox richard-cox force-pushed the pagination-cluster-explorer branch from a17f1d9 to 457f117 Compare January 7, 2025 18:36
@codyrancher codyrancher merged commit f980283 into rancher:master Jan 7, 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
3 participants