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

Remove support for controversial ignore_unavailable and allow_no_indices from indices exists api #20712

Merged
merged 1 commit into from
Nov 4, 2016

Conversation

javanna
Copy link
Member

@javanna javanna commented Sep 30, 2016

Exist requests are supposed to never throw an exception, but rather return true or false depending on whether some resource exists or not. Indices exists does that for indices and accepts wildcard expressions. The way the api works internally is by resolving indices like any other api would do and catching IndexNotFoundException: if an exception is thrown false is returned, otherwise true. That works only if ignore_unavailable and allow_no_indices indices options are both set to false, meaning that they are strict and any missing index or wildcard expression that resolves to no indices leads to an exception that can be thrown and cause false to be returned.

Unfortunately the indices options have been configurable up until now for the indices exists request, meaning that one can set ignore_unavailable or allow_no_indices to true and have the indices exist request return true for indices that really don't exist, which makes very little sense in the context of this api.

For instance curl -iXHEAD localhost:9200/_all?allow_no_indices=true returns 200 OK against an empty cluster. allow_no_indices and ignore_unavailable affect badly what this api returns, hence I think they shouldn't be settable in this specific case.

This commit removes the indicesOptions setter from the IndicesExistsRequest and makes settable only expandWildcardsOpen and expandWildcardsClosed, hence a subset of the available indices options. This way we can guarantee more consistent behaviour of the indices exists api. ignore_unavailable will always be set to false, as well as allow_no_indices.

"allow_no_indices": {
"type" : "boolean",
"description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"
},
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 we should document this a breaking change, just in case users rely on this broken behavior.

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 see it differently. I think it is a bug and we help users that rely on it by fixing it. Otherwise non existing indices cause the api to return true with the "right" indices options, that really makes no sense to rely on I believe :)

Copy link
Member

Choose a reason for hiding this comment

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

I agree it makes no sense and I'm happy with this fix. I just think that a short line saying "params X and Y have been removed from the Indices Exists REST API" in changelog is still valuable. But as you want.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that sounds good. It's just that if we treat it as a breaking change it can't go in a bugfix release, that is what I worry about :)


public IndicesExistsRequest expandWilcardsClosed(boolean expandWildcardsClosed) {
this.indicesOptions = IndicesOptions.fromOptions(indicesOptions.ignoreUnavailable(), indicesOptions.allowNoIndices(),
indicesOptions.expandWildcardsOpen(), expandWildcardsClosed);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could also check that ignore_unavailable and allow_no_indices are equals to false in the validate() method of the request?

Copy link
Member Author

Choose a reason for hiding this comment

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

why? You can't set them.

Copy link
Member

Choose a reason for hiding this comment

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

Ok

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe we should do this in a test, given that if you can set those options something is broken. I will look into this.

@tlrx
Copy link
Member

tlrx commented Oct 3, 2016

ignore_unavailable will always be set to true, as well as allow_no_indices.

Hum.. to falseinstead ?

I left some comments

@javanna
Copy link
Member Author

javanna commented Oct 3, 2016

ignore_unavailable will always be set to true, as well as allow_no_indices.
Hum.. to falseinstead ?

Right, I corrected that. Let me also ping @elastic/es-clients so they can tell us what they think about the change.

@javanna
Copy link
Member Author

javanna commented Oct 3, 2016

I chatted with the clients team and they are fine with this change, they also see it as a bugfix which means that it makes sense to backport it. @tlrx I will add some docs around the breaking change when backporting to 5.0 if that's ok with you.

@javanna javanna force-pushed the fix/indices_exists_options branch from 2abeb1b to c953220 Compare October 3, 2016 13:06
@epixa
Copy link
Contributor

epixa commented Oct 4, 2016

Pardon my ignorance, but is this removing the ability to set ignore_unavailable at request time?

@javanna
Copy link
Member Author

javanna commented Oct 4, 2016

@epixa yes but only for indices exists api. Do you foresee this as a problem? Would love to hear why this "feature" would be needed for this specific api.

@javanna javanna changed the title Remove controversial indicesOptions setter from IndicesExistsRequest Remove support for controversial ignore_unavailable and allow_no_indices from indices exists api Oct 4, 2016
@javanna
Copy link
Member Author

javanna commented Oct 5, 2016

@epixa I updated the title to better reflect what this change is about. Could you please give me some feedback on whether this change could impact kibana? I thought kibana doesn't use this api at all, but I may be wrong. Thanks!

@epixa
Copy link
Contributor

epixa commented Oct 5, 2016

@javanna Thanks for the clarification. I don't think we use the Indices Exists api at all, but I just sent a message to the rest of the Kibana team to see if anyone can think of something that I'm missing. Unfortunately it's kind of hard to grep for this sort of thing in Kibana, so I can't determine if we use it statically.

@javanna
Copy link
Member Author

javanna commented Oct 5, 2016

we don't have many endpoints that support HEAD, maybe grepping HEAD would help, not sure :)

@epixa
Copy link
Contributor

epixa commented Oct 5, 2016

I think we're good on our end. Thanks for your patience!

…ces from indices exists api

Exist requests are supposed to never throw an exception, but rather return true or false depending on whether some resource exists or not. Indices exists does that for indices and accepts wildcard expressions too. The way the api works internally is by resolving indices and catching IndexNotFoundException: if an exception is thrown the index does not exist hence it returns false, otherwise it returns true. That works ok only if ignore_unavailable and allow_no_indices indices options are both set to false, meaning that they are strict and any missing index or wildcard expressions that resolves to no indices will lead to an exception that can be thrown and cause false to be returned.

Unfortunately the indices options have  been configurable up until now for this request, meaning that one can set ignore_unavailable or allow_no_indices to true and have the indices exist request return true for indices that really don't exist, which makes very little sense in the context of this api.

This commit removes the indicesOptions setter from the IndicesExistsRequest and makes settable only expandWildcardsOpen and expandWildcardsClosed, hence a subset of the available indices options. This way we can guarantee more consistent behaviour of the indices exists api. We can then remove the ignore_unavailable and allow_no_indices option from indices exists api spec
@javanna
Copy link
Member Author

javanna commented Nov 2, 2016

@tlrx I got back to this, can you have a final look please?

Copy link
Member

@tlrx tlrx 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 @javanna

@javanna javanna merged commit c2160a8 into elastic:master Nov 4, 2016
@javanna
Copy link
Member Author

javanna commented Nov 4, 2016

@clintongormley I didn't backport this as I saw you have removed 5.0.0 and 5.1.0 labels. Maybe we could consider it as a good enhancement for 5.1.0 though, let me know what you think.

@clintongormley clintongormley changed the title Remove support for controversial ignore_unavailable and allow_no_indices from indices exists api Remove support for controversial ignore_unavailable and allow_no_indices from indices exists api May 5, 2017
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