Fields caps does not honour ignore_unavailable#116021
Fields caps does not honour ignore_unavailable#116021drempapis merged 16 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
…ogic to exclude closed indices to the TransportFieldsCapabilitiesAction class to avoid business-logic conflicts with implementation for other Actions.
|
I updated the code after detecting test failures on ci. I moved the logic to exclude closed indices to the TransportFieldsCapabilitiesAction class to avoid business-logic conflicts with implementation for other Actions. |
| if (metadata != null && metadata.getState() == IndexMetadata.State.CLOSE) { | ||
| if (ignoreUnavailable) return false; | ||
| else throw new IndexClosedException(metadata.getIndex()); | ||
| } else return true; |
There was a problem hiding this comment.
I am a bit outdated on how indices resolution works these days, after recent refactoring. I was somehow not expecting that you need to explicitly handle closed indices, rather that provided indices and indices options, the method does what it needs to do, meaning not return closed indices. Can you double check that that option is no longer possible?
There was a problem hiding this comment.
Thank you, @javanna, for reviewing the pr. You are right. Further debugging the code, I found that for the incoming requests, the allowClosedIndices is set to true. Changing the default value at the FieldCapabilitiesRequest level, mitigates that issue.
…he ignoreUnavailable set in the URL request. Changing that value in the corresponding Request class will make it false.
| public final class FieldCapabilitiesRequest extends ActionRequest implements IndicesRequest.Replaceable, ToXContentObject { | ||
| public static final String NAME = "field_caps_request"; | ||
| public static final IndicesOptions DEFAULT_INDICES_OPTIONS = IndicesOptions.strictExpandOpen(); | ||
| public static final IndicesOptions DEFAULT_INDICES_OPTIONS = IndicesOptions.strictExpandOpenAndForbidClosed(); |
There was a problem hiding this comment.
Nice! I believe this is ok. The doubt I have is just about the fact that we are changing index resolution for the field caps API, and that will affect existing usage. Yet if this is only to avoid errors when targeting closed indices, I think that's the right call, assuming there are no side effects. Are you able to get a green build?
There was a problem hiding this comment.
Thank you, @javanna, I'll proceed with that
There was a problem hiding this comment.
I am not 100% sure I am following this. Why are we changing the default behaviour? Don't we want the change only when we get ignore_unavailable=true?
My reasoning here is: if we target a closed index an we have ignore_unavailable=false we want an error back, while if the request has ignore_unavailable=true we can safely skip closed indices.
There was a problem hiding this comment.
Thank you, @piergm, for the review. The allowClosedIndices is set to true in IndicesOptions.strictExpandOpen(), which affects the URL parameter ignore_unavailable behavior.
In the main branch, having a closed index for any value of ignore_unavailable, we get an exception of type.
cluster_block_exception. After changing the options in the field request, the API works as expected, returning an IndexClosedException for ignore_unavailable=false.
There was a problem hiding this comment.
Oh I see, thank you for the clarification!
server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java
Outdated
Show resolved
Hide resolved
|
@elasticmachine update branch |
|
@elasticmachine update branch |
server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java
Outdated
Show resolved
Hide resolved
|
💚 CLA has been signed |
|
@elasticmachine run elasticsearch-ci/part-4 |
|
@elasticmachine test this please |
|
@elasticmachine update branch |
The IndicesOption has been updated into the FieldCapabilitiesRequest to encapsulate the following logic. If we target a closed index and ignore_unavailable=false, we get an IndexClosedException, otherwise if the request contains ignore_unavailable=true, we safely skip the closed index.
The IndicesOption has been updated into the FieldCapabilitiesRequest to encapsulate the following logic. If we target a closed index and ignore_unavailable=false, we get an IndexClosedException, otherwise if the request contains ignore_unavailable=true, we safely skip the closed index. (cherry picked from commit 3ae7921)
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
The IndicesOption has been updated into the FieldCapabilitiesRequest to encapsulate the following logic. If we target a closed index and ignore_unavailable=false, we get an IndexClosedException, otherwise if the request contains ignore_unavailable=true, we safely skip the closed index.
The IndicesOption has been updated into the FieldCapabilitiesRequest to encapsulate the following logic. If we target a closed index and ignore_unavailable=false, we get an IndexClosedException, otherwise if the request contains ignore_unavailable=true, we safely skip the closed index. (cherry picked from commit 3ae7921)
The IndicesOption has been updated into the FieldCapabilitiesRequest to encapsulate the following logic. If we target a closed index and ignore_unavailable=false, we get an IndexClosedException, otherwise if the request contains ignore_unavailable=true, we safely skip the closed index.
…#199717) - Closes: #199413 - Related: #199654 - Related ES PR: elastic/elasticsearch#116021 - Related ES PR: elastic/elasticsearch#116656 ## Summary This PR unskips tests and updates the Kibana API to the updated ES responses. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
…elastic#199717) - Closes: elastic#199413 - Related: elastic#199654 - Related ES PR: elastic/elasticsearch#116021 - Related ES PR: elastic/elasticsearch#116656 ## Summary This PR unskips tests and updates the Kibana API to the updated ES responses. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit f61c043)
…elastic#199717) - Closes: elastic#199413 - Related: elastic#199654 - Related ES PR: elastic/elasticsearch#116021 - Related ES PR: elastic/elasticsearch#116656 ## Summary This PR unskips tests and updates the Kibana API to the updated ES responses. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
The IndicesOption has been updated into the FieldCapabilitiesRequest to encapsulate the following logic. If we target a closed index and ignore_unavailable=false, we get an IndexClosedException, otherwise if the request contains ignore_unavailable=true, we safely skip the closed index.
…elastic#199717) - Closes: elastic#199413 - Related: elastic#199654 - Related ES PR: elastic/elasticsearch#116021 - Related ES PR: elastic/elasticsearch#116656 ## Summary This PR unskips tests and updates the Kibana API to the updated ES responses. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
Querying an existing and closed index fails with cluster_block_exception when the _field_caps with ignore_unavailable=true is called.
The close State is not considered when filtering "unavailable," missing, or unacceptable resources, propagating closed indices to the method TransportFieldCapabilitiesAction::checkIndexBlocks, which raises an exception.
In this PR, state-related code was added to filter out closed indices.
Closes #107767