[UA] Make reindex error handle more robust (#33060) (#33092)

This commit is contained in:
Tyler Smalley 2019-03-12 23:28:25 -07:00 committed by GitHub
parent d558a2a29a
commit a3574c281c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -412,12 +412,9 @@ export const reindexServiceFactory = (
const { count } = await callCluster('count', { index: reindexOp.attributes.indexName });
if (taskResponse.task.status.created < count) {
if (taskResponse.response.failures && taskResponse.response.failures.length > 0) {
const failureExample = JSON.stringify(taskResponse.response.failures[0]);
throw Boom.badData(`Reindexing failed with failures like: ${failureExample}`);
} else {
throw Boom.badData('Reindexing failed due to new documents created in original index.');
}
// Include the entire task result in the error message. This should be guaranteed
// to be JSON-serializable since it just came back from Elasticsearch.
throw Boom.badData(`Reindexing failed: ${JSON.stringify(taskResponse)}`);
}
// Update the status