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

Propagate index errors in field_caps #70245

Merged
merged 13 commits into from
Apr 6, 2021
Merged

Conversation

cbuescher
Copy link
Member

@cbuescher cbuescher commented Mar 10, 2021

Currently we don't report any exceptions occuring during field_caps requestrs back to the user.
This PR adds a new failure section to the response which contains exceptions per index, keyed by
the index name the error occured in. In addition the response contains another field failed_indices
which reports the number of indices that threw an exception. If all of the requested indices failed,
the whole request fails with a 500 error code, otherwise the request succeeds and it is up to the caller
to check for potential errors in the response body.

Closes #68994

@cbuescher cbuescher added the WIP label Mar 10, 2021
@cbuescher cbuescher force-pushed the fix-68994 branch 6 times, most recently from 8e0e659 to 9995863 Compare March 16, 2021 19:31
@cbuescher
Copy link
Member Author

This is an example of the response with failures with the changes in this PR:

{
	"indices": [...],
	"fields": {
		...
	},
	"failed_indices": 1,
	"failures": {
		"errorindex": {
			"error": {
				"root_cause": [{
					"type": "illegal_argument_exception",
					"reason": "test"
				}],
				"type": "illegal_argument_exception",
				"reason": "test"
			}
		}
	}
}

@cbuescher cbuescher added :Search Foundations/Mapping Index mappings, including merging and defining field types >bug v7.13.0 v8.0.0 and removed WIP labels Mar 17, 2021
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Mar 17, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@cbuescher cbuescher changed the title WIP: Propagate errors in field_caps Propagate index errors in field_caps Mar 17, 2021
Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

The approach looks good to me. I left one comment regarding the reporting of the exception.

@cbuescher
Copy link
Member Author

@jimczi thanks for the review, I will rework the part around how to transport back the exceptions.

@cbuescher
Copy link
Member Author

@jimczi I pushed and update reworking how the exceptions get transported back.

countDown.run();
}, e -> {
// individual index failures should show up as remote responses containing an exception
countDown.run();
Copy link
Contributor

Choose a reason for hiding this comment

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

This case is not handled automatically. We need to add all the indices from that cluster in the index failures map. Since all indices on that cluster failed, maybe that the key in the map could be the cluster name instead ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Individual index failures on a remote should be handled (there is also a test for it now that should fail otherwise). So you mean this should cover general remote failures? How could this happen? Also asking since I cannot thing around a way of testing this atm...

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

Looks good to me. Could you add a test a yml test for ccs as well ?

@Override
public RestStatus status() {
RestStatus status = RestStatus.OK;
if (indices.length == 0 && failures.size() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this logic now that we throw an exception if all indices fail ? We could even assert in the ctr that failures must be empty if indices is empty.

@cbuescher
Copy link
Member Author

@jimczi thanks, I pushed changes that remove the rest status logic you mentioned, reworked the failure collection a bit to be all on a central place and added the test you asked for.

Copy link
Contributor

@jimczi jimczi 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 @cbuescher !

@cbuescher cbuescher merged commit a413ae6 into elastic:master Apr 6, 2021
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Apr 6, 2021
Currently we don't report any exceptions occuring during field_caps requests back to the user.
This PR adds a new failure section to the response which contains exceptions per index.
In addition the response contains another field, `failed_indices`, with the number of indices that threw
an exception. If all of the requested indices fail, the whole request fails, otherwise the request succeeds
and it is up to the caller to check for potential errors in the response body.

Closes elastic#68994
cbuescher pushed a commit that referenced this pull request Apr 6, 2021
Currently we don't report any exceptions occuring during field_caps requests back to the user.
This PR adds a new failure section to the response which contains exceptions per index.
In addition the response contains another field, `failed_indices`, with the number of indices that threw
an exception. If all of the requested indices fail, the whole request fails, otherwise the request succeeds
and it is up to the caller to check for potential errors in the response body.

Closes #68994
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.13.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Field capabilities API drops shard level exceptions
4 participants