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

SQLite backed cache: Support sorting mgmt clusters on value in a specific condition #447

Merged
merged 17 commits into from
Jan 27, 2025

Conversation

ericpromislow
Copy link
Contributor

@ericpromislow ericpromislow commented Jan 13, 2025

Supports the UI to display managed clusters in a "saner" way.

Sample URL:

$ curl -sk https://localhost:5111/v1/management.cattle.io.clusters?sort=-spec.internal,-status.connected,spec.displayName' | jq '.data[] | [.metadata.name, .spec.internal, .status.connected, .spec.displayName]' 
[ "local", true, true,   "local" ]
[ "c-m-qc5fl797", false, true, "eptest-20250113a" ]
[ "c-m-kkjfv6r2",  false,  true,  "eptest-20250113e" ]
[ "c-m-7rp8c77v",  false,   false,  "eptest-20250113b2" ]

This sort order puts the internal clusters first, then ready (secondarily sorting by the cluster's friendly name), then the
non-ready ones.

Note putting a hyphen before boolean fields does a reverse (or DESC) sort, so the true ones appear before the false ones.

Related to #48092

Depends on:
#122 - Only because lasso is doing some sql code-generation that steve should be doing.

@ericpromislow ericpromislow requested a review from a team as a code owner January 13, 2025 20:09
@ericpromislow ericpromislow requested review from moio and tomleb and removed request for a team January 13, 2025 20:09
@ericpromislow ericpromislow marked this pull request as draft January 13, 2025 20:10
Copy link
Contributor

@moio moio left a comment

Choose a reason for hiding this comment

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

Thanks @ericpromislow, this looks good to undraft to me.

As a side note, I see there are three concerns being addressed in this PR:

  • adding support for an arbitrary number of sort conditions
  • adding support for fields containing a dot
  • adding a transformation to the v3 cluster object in order to contain a virtual .connected field in its status

I understand the reasoning behind keeping all of these in one PR, as the end-user concern/ask is actually unique. OTOH, an argument could be made to to split the change into three PRs addressing one concern each, especially because the first two affect non-Vai use cases too.

I will leave it the Frameworks team to make that decision.

From my perspective, most things look good - apart from suggestions there is only a couple of questions that are hopefully quick to settle.

Thanks!

@ericpromislow ericpromislow marked this pull request as ready for review January 16, 2025 20:41
moio
moio previously approved these changes Jan 22, 2025
Copy link
Contributor

@moio moio left a comment

Choose a reason for hiding this comment

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

Looks good from my perspective once the README fully reflects the syntax change introduced.

I guess it can be merged as soon as @tomleb also approves.

Thanks for this contribution!

This should be added to the README for filter queries in the PR for 46333.
moio
moio previously approved these changes Jan 23, 2025
@ericpromislow ericpromislow merged commit c180569 into rancher:main Jan 27, 2025
1 check passed
@ericpromislow ericpromislow deleted the 48092-sort-clusters branch January 27, 2025 19:55
tomleb pushed a commit to tomleb/rancher-steve that referenced this pull request Feb 3, 2025
…cific condition (rancher#447)

* Replace primary/secondary sort fields with an array of sort directives.

* Allow more than 2 sort-params in a search query.

* Add a virtual 'status.ready' field to clusters.

* Rename status.ready -> status.connected

* Set virtual field 'spec.internal' <- spec.displayName == 'local'

* Need to declare all virtual fields to index.

* Ready clusters have condition[type==Ready && status=True]

* Update the README to reflect generalized sorting.

* Bump lasso to get revised sort directives.

* Review-driven changes, mostly comments and drop unneeded code.

* Add unit tests to verify sort-order stringification.

* Ignore empty-string sort components.

* Fix a rebase mishap.

* Drop unneeded commented-out code.

* Clusters have a 'spec.internal' field, no need to synthesize one.

* Added a note on square-brackets for label references.

This should be added to the README for filter queries in the PR for 46333.

* Bump to latest sqlcache-free lasso
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.

3 participants