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

This commit is contained in:
Josh Dover 2019-03-13 00:34:54 -05:00 committed by Tyler Smalley
parent 9b632d0faa
commit 3c60eb1165

View file

@ -359,12 +359,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