-
Notifications
You must be signed in to change notification settings - Fork 2k
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
api: return sorted results in certain list endpoints #12054
Conversation
2ceea96
to
8e0202c
Compare
24f3308
to
54e19b4
Compare
54e19b4
to
21b0a40
Compare
21b0a40
to
a2a6148
Compare
a2a6148
to
065dba1
Compare
065dba1
to
a5727ed
Compare
a5727ed
to
0d4783b
Compare
0d4783b
to
aaa0ccb
Compare
nomad/deployment_endpoint.go
Outdated
return args.ShouldBeFiltered(deployment) | ||
} | ||
return false | ||
}) |
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.
Because we now rely on a _prefix
iterator over namespaces, we need to filter out any deployments that erroneously match the prefix. (e.g. want foo
, but also matches fooo
).
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.
Maybe it would be worth having a test for this? Just to make sure the behaviour or ShouldBeFiltered
changes unexpectedly.
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.
Minor comments. I think it would be nice to have a CLI flag as well, but that can come in a follow-up PR.
The api
package update question I don't really know the answer, but I think that, without changes, it wouldn't be possible to use the new parameter?
nomad/structs/structs.go
Outdated
@@ -859,6 +859,8 @@ type EvalDequeueRequest struct { | |||
type EvalListRequest struct { | |||
FilterJobID string | |||
FilterEvalStatus string | |||
FilterNamespace string |
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.
Do we need a new namespace filter? What's the difference from QueryOptions.Namespace
?
nomad/deployment_endpoint.go
Outdated
return args.ShouldBeFiltered(deployment) | ||
} | ||
return false | ||
}) |
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.
Maybe it would be worth having a test for this? Just to make sure the behaviour or ShouldBeFiltered
changes unexpectedly.
These API endpoints now return results in chronological order. They can return results in reverse chronological order by setting the query parameter ascending=true. - Eval.List - Deployment.List
aaa0ccb
to
b432f37
Compare
The paginator logic was built when go-memdb iterators would return items ordered lexicographically by their prefixes, but #12054 added the option for some tables to return results ordered by their `CreateIndex` instead, which invalidated the previous paginator assumption. This fix changes the paginator so that it skips values that are different from the token bein searched instead of just smaller ones.
The paginator logic was built when go-memdb iterators would return items ordered lexicographically by their ID prefixes, but #12054 added the option for some tables to return results ordered by their `CreateIndex` instead, which invalidated the previous paginator assumption. The iterator used for pagination must still return results in some order so that the paginator can properly handle requests where the next_token value is not present in the results anymore (e.g., the eval was GC'ed). In these situations, the paginator will start the returned page in the first element right after where the requested token should've been. This commit moves the logic to generate pagination tokens from the elements being paginated to the iterator itself so that callers can have more control over the token format to make sure they are properly ordered and stable. It also allows configuring the paginator as being ordered in ascending or descending order, which is relevant when looking for a token that may not be present anymore.
The paginator logic was built when go-memdb iterators would return items ordered lexicographically by their ID prefixes, but #12054 added the option for some tables to return results ordered by their `CreateIndex` instead, which invalidated the previous paginator assumption. The iterator used for pagination must still return results in some order so that the paginator can properly handle requests where the next_token value is not present in the results anymore (e.g., the eval was GC'ed). In these situations, the paginator will start the returned page in the first element right after where the requested token should've been. This commit moves the logic to generate pagination tokens from the elements being paginated to the iterator itself so that callers can have more control over the token format to make sure they are properly ordered and stable. It also allows configuring the paginator as being ordered in ascending or descending order, which is relevant when looking for a token that may not be present anymore.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
These API endpoints now return results in chronological order. They
can return results in reverse chronological order by setting the
query parameter ascending=true.
We can add more endpoints following the same pattern. But lets get these out of the way first and see if what we're doing here actually makes sense / is necessary in light of
go-bexpr
.Parts of #11742