diff --git a/src/core/server/saved_objects/migrationsv2/actions/clone_index.ts b/src/core/server/saved_objects/migrationsv2/actions/clone_index.ts index 5674535c80328..d7994f5a465d2 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/clone_index.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/clone_index.ts @@ -127,11 +127,11 @@ export const cloneIndex = ({ // If the cluster state was updated and all shards ackd we're done return TaskEither.right(res); } else { - // Otherwise, wait until the target index has a 'green' status. + // Otherwise, wait until the target index has a 'yellow' status. return pipe( waitForIndexStatusYellow({ client, index: target, timeout }), TaskEither.map((value) => { - /** When the index status is 'green' we know that all shards were started */ + /** When the index status is 'yellow' we know that all shards were started */ return { acknowledged: true, shardsAcknowledged: true }; }) ); diff --git a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts index 173f2baefbb9b..b85fb0257d15c 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts @@ -410,14 +410,15 @@ describe('migration actions', () => { timeout: '0s', })(); - await expect(cloneIndexPromise).resolves.toMatchObject({ - _tag: 'Left', - left: { - error: expect.any(errors.ResponseError), - message: expect.stringMatching(/\"timed_out\":true/), - type: 'retryable_es_client_error', - }, - }); + await expect(cloneIndexPromise).resolves.toMatchInlineSnapshot(` + Object { + "_tag": "Left", + "left": Object { + "message": "Timeout waiting for the status of the [clone_red_index] index to become 'yellow'", + "type": "retryable_es_client_error", + }, + } + `); }); }); diff --git a/src/core/server/saved_objects/migrationsv2/actions/wait_for_index_status_yellow.ts b/src/core/server/saved_objects/migrationsv2/actions/wait_for_index_status_yellow.ts index 2880dfaff0d48..9d4df0ced8c0b 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/wait_for_index_status_yellow.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/wait_for_index_status_yellow.ts @@ -40,8 +40,18 @@ export const waitForIndexStatusYellow = }: WaitForIndexStatusYellowParams): TaskEither.TaskEither => () => { return client.cluster - .health({ index, wait_for_status: 'yellow', timeout }) - .then(() => { + .health({ + index, + wait_for_status: 'yellow', + timeout, + }) + .then((res) => { + if (res.body.timed_out === true) { + return Either.left({ + type: 'retryable_es_client_error' as const, + message: `Timeout waiting for the status of the [${index}] index to become 'yellow'`, + }); + } return Either.right({}); }) .catch(catchRetryableEsClientErrors);