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 a capabilities API to check node and cluster capabilities #106820

Merged
merged 16 commits into from
May 8, 2024

Conversation

thecoop
Copy link
Member

@thecoop thecoop commented Mar 27, 2024

Add a _capabilities REST api and corresponding transport actions to support checking for node capabilities across a cluster.

This adds RestController to the injector. There's now a circular dependency between the capabilities REST handler, the transport actions, and the RestController, but that's unavoidable due to what the transport action actually has to do.

@thecoop thecoop force-pushed the node-capabilities branch from 92e11ec to 1bc5b0e Compare March 27, 2024 15:53
@thecoop thecoop added WIP :Core/Infra/REST API REST infrastructure and utilities labels Mar 28, 2024
@thecoop thecoop marked this pull request as ready for review March 28, 2024 11:44
Copy link
Contributor

@mosche mosche left a comment

Choose a reason for hiding this comment

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

Already looking quite good, Simon! 🎉

In yaml / bwc test we have to stick with historical features, i suppose. Considering we have to start annotating a decent amount of existing endpoints for the current version, we certainly don't want to do that multiple times for past versions as well (I hope 😁 ).

@thecoop thecoop requested a review from a team April 12, 2024 12:31
@thecoop
Copy link
Member Author

thecoop commented Apr 12, 2024

Currently all capability checks of invalid APIs actually return supported, due to wildcards matching more than it should. Created #107425 to discuss this

Add test for random invalid api
@mosche
Copy link
Contributor

mosche commented Apr 22, 2024

LGTM except for the open naming part, but I think we've got some decent options to pick from above 👍

@thecoop
Copy link
Member Author

thecoop commented May 7, 2024

Reducing the scope of rest handler wildcards is proving extremely problematic - we may need to merge this without changing wildcards.

This will mean that checking for endpoint capabilities (does this node support /foo/bar at all) will return true most of the time, even if the node does not actually support it, as a wildcard will match the path most of the time. Other aspect checks will work correctly though

@rjernst
Copy link
Member

rjernst commented May 7, 2024

This will mean that checking for endpoint capabilities (does this node support /foo/bar at all) will return true most of the time

That seems to defeat the purpose of the api, effectively making this a one way test "Is this API definitely available"? but not "Is this api not available?"

@thecoop
Copy link
Member Author

thecoop commented May 7, 2024

But it will enable this to be used to check for endpoint features, which is the main use case people are asking for at the moment

Copy link
Member

@rjernst rjernst 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, but I think we should not overload the "features" terminology more

@@ -77,6 +78,13 @@ public final long getUsageCount() {

@Override
public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
// check if the query has any parameters that are not in the supported set (if declared)
Set<String> supported = supportedQueryParameters();
if (supported != null && supported.containsAll(request.params().keySet()) == false) {
Copy link
Member

Choose a reason for hiding this comment

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

This check seems like it removes the need for the unconsumed parameters infra below, since it more directly checks whether a parameter is supported, rather the current "anything unused must be unsupported"? This can be a followup, but it seems like that could be removed after this change (or at least once all apis have supportedQueryParams setup?)

Copy link
Member Author

Choose a reason for hiding this comment

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

They've got slightly different use cases - see #106820 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think they are different use cases. The reason we check if params are "consumed" was as a way to check if params are valid without explicitly defining which params are valid. But we can discuss if/how to remove param consumption check after merging this one.

@thecoop thecoop requested a review from mosche May 7, 2024 16:08
Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mosche mosche left a comment

Choose a reason for hiding this comment

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

🎉 LGTM

@thecoop thecoop removed the WIP label May 8, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label May 8, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine
Copy link
Collaborator

Hi @thecoop, I've created a changelog YAML for you.

@thecoop thecoop merged commit e7350dc into elastic:main May 8, 2024
2 of 15 checks passed
@thecoop thecoop deleted the node-capabilities branch May 8, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/REST API REST infrastructure and utilities >feature Team:Core/Infra Meta label for core/infra team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants