mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
migrations: handle 200 response code from _cluster/health API on timeout
This commit is contained in:
parent
30493f90be
commit
853a0126fc
3 changed files with 23 additions and 12 deletions
|
@ -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 };
|
||||
})
|
||||
);
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
}
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -40,8 +40,18 @@ export const waitForIndexStatusYellow =
|
|||
}: WaitForIndexStatusYellowParams): TaskEither.TaskEither<RetryableEsClientError, {}> =>
|
||||
() => {
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue