Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrations: handle 200 response code from _cluster/health API on timeout #117879

Merged
merged 2 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}
`);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down