-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Storage: Add support for sortBy selector #80680
Conversation
https://clusterpedia.io/docs/usage/search/multi-cluster/#sorting-by-multiple-fields -- is an interesting alternative. In that model, we would support something like:
I like they this more explicitly flips things to a "search" context +1 for offset -- i can't think of a better option, the downside is if things get modified or deleted between page requests 😬 |
I would be absolutely fine with switching to label selectors which would give us more flexibility (and more concise kubectl cli syntax), if we do that would you want to keep folder as a field selector or just flip everything back to label selectors? |
tests are now working, but the sqlite "database table is locked" issue is popping up when running migrations against sqlite. |
yeah, I figured if the migrations had succeeded then the name didn't really
matter, but it won't hurt to increment it.
…On Tue, Jan 23, 2024 at 1:06 PM Ryan McKinley ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pkg/services/store/entity/migrations/entity_store_mig.go
<#80680 (comment)>:
> @@ -120,7 +120,11 @@ func initEntityTables(mg *migrator.Migrator) string {
},
Indices: []*migrator.Index{
{Cols: []string{"guid", "resource_version"}, Type: migrator.UniqueIndex},
- {Cols: []string{"namespace", "group", "resource", "name", "resource_version"}, Type: migrator.UniqueIndex},
+ {
+ Cols: []string{"namespace", "group", "resource", "name", "resource_version"},
be sure the change the "marker" above so this migration happens on
existing setups. (yes it will wipe out everything first)
—
Reply to this email directly, view it on GitHub
<#80680 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALAOEY7XVDT6LDTVZIE4OTYP733HAVCNFSM6AAAAABB5SQXJ2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQMZZGUZDGMJZGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a couple of small comments and a question. I plan on looking into the code some more later on.
pkg/services/grafana-apiserver/storage/entity/fieldRequirements.go
Outdated
Show resolved
Hide resolved
pkg/services/grafana-apiserver/storage/entity/fieldRequirements.go
Outdated
Show resolved
Hide resolved
pkg/services/grafana-apiserver/storage/entity/fieldRequirements.go
Outdated
Show resolved
Hide resolved
f458665
to
3eb61fb
Compare
3eb61fb
to
902fee1
Compare
bb19f34
to
7636595
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
* add support for sortBy field selector * use label selectors instead of field selectors * set entity_labels on create & update * make entity server integration tests work * test fixes * be more consistent with handling of empty body, meta or status * workaround for database is locked errors during migration * fix double import of sqlite3 * rename functions and tidy up * refactor update * disable integration tests until we can fix the database locking issue
This PR adds support for sorting lists by specifying a field selector like
grafana.app/sortBy="title"
, including support for paging.I opted to implement paging via offset rather than uids because of the complexity involved in building where clauses when sorting by multiple dimensions (e.g. for
grafana.app/sortBy=a;b desc
theWHERE
clause would need to be(a > ? OR (a = ? AND (b < ? OR (b = ? AND uid > ?)))
) vs the simplicity of an offset-based approach.The other change from our standard semantics is that when specifying multiple columns the separator is a semicolon rather than a comma, using a comma resulted in an error from the k8s field selector parser like:
This appears to be due to the chained selectors syntax which supports sending multiple field selector expressions separated with commas.
Will take this out of draft status once I've had a chance to add tests.