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

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

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!

go.mod Outdated Show resolved Hide resolved
pkg/resources/virtual/clusters/clusters.go Outdated Show resolved Hide resolved
Comment on lines +362 to +369
//itfs := make([]interface{}, len(field))
//for j, f := range field {
// itfs[j] = f
//}
//leftValue := convert.ToString(data.GetValueN(leftNode, itfs...))
//rightValue := convert.ToString(data.GetValueN(rightNode, itfs...))
Copy link
Contributor

Choose a reason for hiding this comment

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

reminder: remove when undrafting

pkg/resources/virtual/clusters/clusters.go Outdated Show resolved Hide resolved
pkg/resources/virtual/clusters/clusters.go Outdated Show resolved Hide resolved
pkg/stores/queryhelper/safesplit.go Outdated Show resolved Hide resolved
pkg/stores/queryhelper/safesplit.go Show resolved Hide resolved
@@ -187,9 +187,9 @@ The list can be negated to exclude results:

#### `sort`
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to add a paragraph about the chance in the syntax of accessing properties with dot in their name, as the square brackets syntax is new.

pkg/stores/partition/listprocessor/processor.go Outdated Show resolved Hide resolved
pkg/stores/partition/listprocessor/processor.go Outdated Show resolved Hide resolved
@ericpromislow ericpromislow marked this pull request as ready for review January 16, 2025 20:41
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.

2 participants