Resolves a race condition where ES is technically up, but the Kibana index is not. Closes #25027 Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
parent
a988f198ae
commit
3e74a2c80b
|
@ -150,8 +150,10 @@ export async function write(callCluster: CallCluster, index: string, docs: RawDo
|
|||
export async function migrationsUpToDate(
|
||||
callCluster: CallCluster,
|
||||
index: string,
|
||||
migrationVersion: MigrationVersion
|
||||
migrationVersion: MigrationVersion,
|
||||
retryCount: number = 10
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const indexInfo = await fetchInfo(callCluster, index);
|
||||
|
||||
if (!_.get(indexInfo, 'mappings.doc.properties.migrationVersion')) {
|
||||
|
@ -183,6 +185,16 @@ export async function migrationsUpToDate(
|
|||
});
|
||||
|
||||
return count === 0;
|
||||
} catch (e) {
|
||||
// retry for Service Unavailable
|
||||
if (e.status !== 503 || retryCount === 0) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
await new Promise(r => setTimeout(r, 1000));
|
||||
|
||||
return await migrationsUpToDate(callCluster, index, migrationVersion, retryCount - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue