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

"local" parameter only in compatible cat requests #3096

Merged
merged 5 commits into from
Nov 8, 2024

Conversation

l-trotta
Copy link
Contributor

@l-trotta l-trotta commented Nov 5, 2024

Followup of #3059, removing local from common cat parameters and adding it only to those requests which allow it.
I can't test it with java because it has its own handcrafted test types, but it seems straightforward enough.

@l-trotta l-trotta requested a review from a team as a code owner November 5, 2024 15:42
@l-trotta l-trotta requested a review from pquentin November 5, 2024 15:42
Copy link
Contributor

github-actions bot commented Nov 5, 2024

Following you can find the validation results for the APIs you have changed.

API Status Request Response
cat.allocation 🟢 12/12 12/12
cat.component_templates Missing test Missing test
cat.indices 🟢 33/33 32/32
cat.master 🟢 1/1 1/1
cat.nodeattrs 🟢 5/5 5/5
cat.pending_tasks 🟢 1/1 1/1
cat.plugins 🟢 2/2 2/2
cat.segments 🟢 9/9 9/9
cat.templates 🟢 17/17 17/17
cat.thread_pool 🟢 9/9 9/9

You can validate these APIs yourself by using the make validate target.

Copy link
Contributor

github-actions bot commented Nov 5, 2024

Following you can find the validation results for the APIs you have changed.

API Status Request Response
cat.allocation 🟢 12/12 12/12
cat.component_templates Missing test Missing test
cat.indices 🟢 33/33 32/32
cat.master 🟢 1/1 1/1
cat.nodeattrs 🟢 5/5 5/5
cat.pending_tasks 🟢 1/1 1/1
cat.plugins 🟢 2/2 2/2
cat.segments 🟢 9/9 9/9
cat.templates 🟢 17/17 17/17
cat.thread_pool 🟢 9/9 9/9

You can validate these APIs yourself by using the make validate target.

Copy link
Member

@JoshMock JoshMock left a comment

Choose a reason for hiding this comment

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

One question, but if we're comfortable with the duplication this LGTM.

@@ -28,4 +28,15 @@ import { CatRequestBase } from '@cat/_types/CatBase'
* @doc_id cat-nodeattrs
* @cluster_privileges monitor
*/
export interface Request extends CatRequestBase {}
export interface Request extends CatRequestBase {
Copy link
Member

Choose a reason for hiding this comment

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

To reduce code duplication, would it help to add a CatWithLocalRequestBase that each of these can extend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure that works too, I'll do it

Copy link
Member

Choose a reason for hiding this comment

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

This requires a change in the compiler:

// CatRequestBase is special as it's a "marker" base class that doesn't imply a property body type. We should get rid of it.
} else if (parent.name === 'CatRequestBase' && parent.namespace === 'cat._types') {
// nothing to do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't think it's worth modifying the compiler for cat, so if it's okay I'd merge it as is

Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks! The approach looks good. I don't think _cat/indices supports ?local.

Comment on lines 76 to 83
/**
* If `true`, the request computes the list of selected nodes from the
* local cluster state. If `false` the list of selected nodes are computed
* from the cluster state of the master node. In both cases the coordinating
* node will send requests for further information to each selected node.
* @server_default false
*/
local?: boolean
Copy link
Member

Choose a reason for hiding this comment

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

local isn't in the JSON spec or the source for _cat/indices: https://github.com/elastic/elasticsearch/blob/35c6b60c773917b48c93b428305ba844f6a27903/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java#L59

Suggested change
/**
* If `true`, the request computes the list of selected nodes from the
* local cluster state. If `false` the list of selected nodes are computed
* from the cluster state of the master node. In both cases the coordinating
* node will send requests for further information to each selected node.
* @server_default false
*/
local?: boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it doesn't reject it like the other requests which doesn't support it. I think it just does nothing though, I'm removing it

Copy link
Contributor

github-actions bot commented Nov 8, 2024

Following you can find the validation results for the APIs you have changed.

API Status Request Response
cat.allocation 🟢 12/12 12/12
cat.component_templates Missing test Missing test
cat.master 🟢 1/1 1/1
cat.nodeattrs 🟢 5/5 5/5
cat.pending_tasks 🟢 1/1 1/1
cat.plugins 🟢 2/2 2/2
cat.segments 🟢 9/9 9/9
cat.templates 🟢 17/17 17/17
cat.thread_pool 🟢 9/9 9/9

You can validate these APIs yourself by using the make validate target.

Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM.

@l-trotta l-trotta merged commit 2bf3907 into main Nov 8, 2024
6 checks passed
@l-trotta l-trotta deleted the correct-cat-requests-local branch November 8, 2024 08:55
pquentin pushed a commit that referenced this pull request Dec 18, 2024
* local parameter only in compatible cat requests

* fix import

* format

* regenerate output

* removed local from cat indices

(cherry picked from commit 2bf3907)

# Conflicts:
#	output/schema/validation-errors.json
@pquentin
Copy link
Member

💚 All backports created successfully

Status Branch Result
8.x

Questions ?

Please refer to the Backport tool documentation

pquentin pushed a commit that referenced this pull request Dec 18, 2024
* local parameter only in compatible cat requests

* fix import

* format

* regenerate output

* removed local from cat indices

(cherry picked from commit 2bf3907)
@pquentin
Copy link
Member

💚 All backports created successfully

Status Branch Result
8.17

Questions ?

Please refer to the Backport tool documentation

pquentin added a commit that referenced this pull request Dec 18, 2024
* "local" parameter only in compatible cat requests (#3096)

* local parameter only in compatible cat requests

* fix import

* format

* regenerate output

* removed local from cat indices

(cherry picked from commit 2bf3907)

# Conflicts:
#	output/schema/validation-errors.json

* Add `local` to cat aliases as it's supported in 8.x

---------

Co-authored-by: Laura Trotta <[email protected]>
pquentin added a commit that referenced this pull request Dec 18, 2024
* "local" parameter only in compatible cat requests (#3096)

* local parameter only in compatible cat requests

* fix import

* format

* regenerate output

* removed local from cat indices

(cherry picked from commit 2bf3907)

* Add `local` to cat aliases as it's supported in 8.x

---------

Co-authored-by: Laura Trotta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants