-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
The ignore_unavailable
option should also ignore indices that are closed
#6475
The ignore_unavailable
option should also ignore indices that are closed
#6475
Conversation
|
||
public String[] concreteIndices(IndicesOptions indicesOptions, boolean canFailClosed, String... aliasesOrIndices) throws IndexMissingException, ElasticsearchIllegalArgumentException { |
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.
Can we avoid having different public concreteIndices
variations? I'd love it if the new flag was part of the IndicesOptions...
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.
The 'ignore_unavailable' option should cover both closed and missing indices, but there is a difference between apis. For example search, count and percolate throw cluster block exception when an index is closed, while update setting, mappings etc allow to be executed on a closed index (in fact certain settings can only be changed on a closed index). This difference isn't expressed in IndicesOptions, we can add it, but IMO it shouldn't be exposed as a setting (apis either never ignore closed indices or do ignore/fail closed indices).
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.
I see your point, on the other hand I think we can have options that are part of IndicesOptions
although not exposed to users, even if they change only depending on the api. That was the direction in #6169. It would be great if we can keep a single concreteIndices
method that knows what to do based on the IndicesOptions
provided as argument and move this canFailClosed
flag to IndicesOptions
without exposing it to users.
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.
+1 I'll update the PR.
On 12 June 2014 12:38, Luca Cavanna notifications@github.com wrote:
In src/main/java/org/elasticsearch/cluster/metadata/MetaData.java:
- public String[] concreteIndices(IndicesOptions indicesOptions, boolean canFailClosed, String... aliasesOrIndices) throws IndexMissingException, ElasticsearchIllegalArgumentException {
I see your point, on the other hand I think we can have options that are
part of IndicesOptions although not exposed to users, even if they change
only depending on the api. That was the direction in #6169
#6169. It would be
great if we can keep a single concreteIndices method that knows what to
do based on the IndicesOptions provided as argument and move this
canFailClosed flag to IndicesOptions without exposing it to users.—
Reply to this email directly or view it on GitHub
https://github.com/elasticsearch/elasticsearch/pull/6475/files#r13695415
.
Met vriendelijke groet,
Martijn van Groningen
@javanna I updated the PR and moved the 'canFailClosed' to IgnoreIndices. |
boolean allowNoIndices = IndicesOptions.strictExpandOpen().allowNoIndices(); | ||
boolean expandWildcardsOpen = IndicesOptions.strictExpandOpen().expandWildcardsOpen(); | ||
boolean expandWildcardsClosed = IndicesOptions.strictExpandOpen().expandWildcardsClosed(); | ||
IndicesOptions defaultOptions = indicesOptions; |
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.
not sure if you wanted to do the following instead?
IndicesOptions defaultOptions = IndicesOptions.strictExpandOpenAndForbidClosed();
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.
The indicesOptions
field is already set to IndicesOptions.strictExpandOpenAndForbidClosed()
, so this should be ok?
Left a few comments, looks good though |
Thanks @javanna, I updated the PR. |
return actualIndices.toArray(new String[actualIndices.size()]); | ||
} else { | ||
return aliasesOrIndices; | ||
} |
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.
This code block is an optimization that's useful in case there's no aliases in the input argument and we can return that same array quickly as we received it. I wonder if it still makes sense to have this optimization given that we might need to modify the array. I would love to remove it as it adds complexity... What do you think @martijnvg?
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.
Most of the times requested indices aren't closed indices, so I think in that case the additional checks is worth it.
Left a small comment, LGTM otherwise |
@javanna Thanks for reviewing it! |
…re closed. Closes elastic#6471 Closes elastic#6475
Side note: this change makes it possible to ignore closed indices when using the |
…tion on closed indices Single index operations to use the newly added IndexClosedException introduced with elastic#6475. This way we can also fail faster when we are trying to execute operations on closed indices and their use is not allowed (depending on indices options). Indices blocks are still checked but we can already throw error while resolving indices (MetaData#concreteIndices). Effectively this change also affects what we return when using one of the following apis: analyze, bulk, index, update, delete, explain, get, multi_get, mlt, term vector, multi_term vector. We now return `{"error":"IndexClosedException[[test] closed]","status":403}` instead of `{"error":"ClusterBlockException[blocked by: [FORBIDDEN/4/index closed];]","status":403}`. Closes elastic#6988
…tion on closed indices Single index operations to use the newly added IndexClosedException introduced with #6475. This way we can also fail faster when we are trying to execute operations on closed indices and their use is not allowed (depending on indices options). Indices blocks are still checked but we can already throw error while resolving indices (MetaData#concreteIndices). Effectively this change also affects what we return when using one of the following apis: analyze, bulk, index, update, delete, explain, get, multi_get, mlt, term vector, multi_term vector. We now return `{"error":"IndexClosedException[[test] closed]","status":403}` instead of `{"error":"ClusterBlockException[blocked by: [FORBIDDEN/4/index closed];]","status":403}`. Closes #6988
ignore_unavailable
option should also ignore indices that are closed
…re closed. Closes elastic#6471 Closes elastic#6475
The
ignore_unavailable
option should also ignore indices that are closed, but it doesn't at the moment. The PR makes sure thatignore_unavailable
also ignores specified indices that are closed.PR for #6471