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

Whitelist node stats indices level parameter #21024

Merged
merged 4 commits into from
Oct 20, 2016
Merged

Whitelist node stats indices level parameter #21024

merged 4 commits into from
Oct 20, 2016

Conversation

jasontedor
Copy link
Member

@jasontedor jasontedor commented Oct 19, 2016

When indices stats are requested via the node stats API, there is a
level parameter to request stats at the index, node, or shards
level. This parameter was not whitelisted when URL parsing was made
strict. This commit whitelists this parameter.

Additionally, there was some leniency in the parsing of this parameter
that has been removed.

Relates #20722

When indices stats are requested via the node stats API, there is a
level parameter to request stats at the index, node, or shards
level. This parameter was not whitelisted when URL parsing was made
strict. This commit whitelists this parameter.

Additionally, there was some leniency in the parsing of this parameter
that has been removed.
Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

left a couple of comments on testing

protected Set<String> responseParams() {
return RESPONSE_PARAMS;
}

Copy link
Member

Choose a reason for hiding this comment

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

it would be good to have a test that verifies that the param is whitelisted?

Copy link
Member Author

Choose a reason for hiding this comment

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

We have general tests in BaseRestHandlerTests for verifying whitelisted parameters works. Do you still think a more specific test is needed here?

Copy link
Member

Choose a reason for hiding this comment

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

I think all we need is a yaml test that uses the parameter or an example of using the parameter in the docs, right? Then we test that this specific parameter is whitelisted.

Copy link
Member

@javanna javanna Oct 19, 2016

Choose a reason for hiding this comment

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

I see. I was wondering if there was a way to catch that we forgot about it. We test that whitelisted settings work I think, so now that it is whitelisted it works for sure, but what if we un-whitelist it by mistake? :) do you see what I mean? That said I am not sure, maybe we could add a small rest test to the existing ones that leverages this param?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add a small REST test. 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed 748235d.

if (!isLevelValid) {
return builder;
throw new IllegalArgumentException("level parameter must be one of [indices] or [node] or [shards] but was [" + level + "]");
Copy link
Member

Choose a reason for hiding this comment

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

should we have a test for this check? It is kinda breaking but if it goes in 5.0 it should be ok I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed 62f055e.

This commit adds a basic REST test for the level parameter on the
indices metric for the nodes stats API.
This commit adds a simple test that NodeIndicesStats#toXContent throws
an IllegalArgumentException if the level parameter is invalid.
@jasontedor
Copy link
Member Author

Thanks for reviewing @javanna; I've pushed commits in response to your comments.

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

LGTM thanks @jasontedor

This commit fixes a line length violation in NodeIndicesStatsTests.java.
@jasontedor jasontedor merged commit 7a55cca into elastic:master Oct 20, 2016
@jasontedor jasontedor deleted the indices-stats-level branch October 20, 2016 02:01
jasontedor added a commit that referenced this pull request Oct 20, 2016
When indices stats are requested via the node stats API, there is a
level parameter to request stats at the index, node, or shards
level. This parameter was not whitelisted when URL parsing was made
strict. This commit whitelists this parameter.

Additionally, there was some leniency in the parsing of this parameter
that has been removed.

Relates #21024
jasontedor added a commit that referenced this pull request Oct 20, 2016
When indices stats are requested via the node stats API, there is a
level parameter to request stats at the index, node, or shards
level. This parameter was not whitelisted when URL parsing was made
strict. This commit whitelists this parameter.

Additionally, there was some leniency in the parsing of this parameter
that has been removed.

Relates #21024
@jasontedor
Copy link
Member Author

Thanks @javanna.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants