Ignore 404 when wiping data streams. (#62492)

Backport of #62484 to 7.x branch.

It is possible in mixed version clusters (nodes prior to 7.10)
that a 404 is returned when wiping all data streams.

This is because there are no data streams and
the coordinator node is on a version that doesn't
mark the delete request for wildcard usage.
This commit is contained in:
Martijn van Groningen 2020-09-17 11:04:05 +02:00 committed by GitHub
parent 63afc61b08
commit 11cef15b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -695,8 +695,10 @@ public abstract class ESRestTestCase extends ESTestCase {
adminClient().performRequest(new Request("DELETE", "_data_stream/*"));
}
} catch (ResponseException e) {
// We hit a version of ES that doesn't have data streams enabled so it's safe to ignore
if (e.getResponse().getStatusLine().getStatusCode() != 405 && e.getResponse().getStatusLine().getStatusCode() != 500) {
// We hit a version of ES that doesn't serialize DeleteDataStreamAction.Request#wildcardExpressionsOriginallySpecified field or
// that doesn't support data streams so it's safe to ignore
int statusCode = e.getResponse().getStatusLine().getStatusCode();
if (org.elasticsearch.common.collect.Set.of(404, 405, 500).contains(statusCode) == false) {
throw e;
}
}