diff --git a/src/core/server/saved_objects/migrationsv2/actions/index.test.ts b/src/core/server/saved_objects/migrationsv2/actions/index.test.ts index 159bf6b042f8a..05da335d70884 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/index.test.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/index.test.ts @@ -37,7 +37,7 @@ describe('actions', () => { describe('fetchIndices', () => { it('calls catchRetryableEsClientErrors when the promise rejects', async () => { - const task = Actions.fetchIndices({ client, indicesToFetch: ['my_index'] }); + const task = Actions.fetchIndices({ client, indices: ['my_index'] }); try { await task(); } catch (e) { diff --git a/src/core/server/saved_objects/migrationsv2/actions/index.ts b/src/core/server/saved_objects/migrationsv2/actions/index.ts index a6f61a521b7ac..905d64947298e 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/index.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/index.ts @@ -71,7 +71,7 @@ export type FetchIndexResponse = Record< /** @internal */ export interface FetchIndicesParams { client: ElasticsearchClient; - indicesToFetch: string[]; + indices: string[]; } /** @@ -80,14 +80,14 @@ export interface FetchIndicesParams { */ export const fetchIndices = ({ client, - indicesToFetch, + indices, }: FetchIndicesParams): TaskEither.TaskEither => // @ts-expect-error @elastic/elasticsearch IndexState.alias and IndexState.mappings should be required () => { return client.indices .get( { - index: indicesToFetch, + index: indices, ignore_unavailable: true, // Don't return an error for missing indices. Note this *will* include closed indices, the docs are misleading https://github.com/elastic/elasticsearch/issues/63607 }, { ignore: [404], maxRetries: 0 } @@ -1174,7 +1174,7 @@ export interface BulkOverwriteTransformedDocumentsParams { client: ElasticsearchClient; index: string; transformedDocs: SavedObjectsRawDoc[]; - refresh: estypes.Refresh; + refresh?: estypes.Refresh; } /** * Write the up-to-date transformed documents to the index, overwriting any @@ -1184,7 +1184,7 @@ export const bulkOverwriteTransformedDocuments = ({ client, index, transformedDocs, - refresh, + refresh = false, }: BulkOverwriteTransformedDocumentsParams): TaskEither.TaskEither< RetryableEsClientError, 'bulk_index_succeeded' diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/actions.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/actions.test.ts index b348eb69c4c16..67a2685caf3d6 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/actions.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/actions.test.ts @@ -116,7 +116,7 @@ describe('migration actions', () => { describe('fetchIndices', () => { it('resolves right empty record if no indices were found', async () => { expect.assertions(1); - const task = fetchIndices({ client, indicesToFetch: ['no_such_index'] }); + const task = fetchIndices({ client, indices: ['no_such_index'] }); await expect(task()).resolves.toMatchInlineSnapshot(` Object { "_tag": "Right", @@ -128,7 +128,7 @@ describe('migration actions', () => { expect.assertions(1); const res = (await fetchIndices({ client, - indicesToFetch: ['no_such_index', 'existing_index_with_docs'], + indices: ['no_such_index', 'existing_index_with_docs'], })()) as Either.Right; expect(res.right).toEqual( diff --git a/src/core/server/saved_objects/migrationsv2/next.ts b/src/core/server/saved_objects/migrationsv2/next.ts index e43223688d4bc..3c3e3c46a8d68 100644 --- a/src/core/server/saved_objects/migrationsv2/next.ts +++ b/src/core/server/saved_objects/migrationsv2/next.ts @@ -58,7 +58,7 @@ export type ResponseType = UnwrapPromise< export const nextActionMap = (client: ElasticsearchClient, transformRawDocs: TransformRawDocs) => { return { INIT: (state: InitState) => - Actions.fetchIndices({ client, indicesToFetch: [state.currentAlias, state.versionAlias] }), + Actions.fetchIndices({ client, indices: [state.currentAlias, state.versionAlias] }), WAIT_FOR_YELLOW_SOURCE: (state: WaitForYellowSourceState) => Actions.waitForIndexStatusYellow({ client, index: state.sourceIndex.value }), SET_SOURCE_WRITE_BLOCK: (state: SetSourceWriteBlockState) => @@ -154,12 +154,11 @@ export const nextActionMap = (client: ElasticsearchClient, transformRawDocs: Tra * before we reach out to the MARK_VERSION_INDEX_READY step. * Right now, it's performed during OUTDATED_DOCUMENTS_REFRESH step. */ - refresh: false, }), MARK_VERSION_INDEX_READY: (state: MarkVersionIndexReady) => Actions.updateAliases({ client, aliasActions: state.versionIndexReadyActions.value }), MARK_VERSION_INDEX_READY_CONFLICT: (state: MarkVersionIndexReadyConflict) => - Actions.fetchIndices({ client, indicesToFetch: [state.currentAlias, state.versionAlias] }), + Actions.fetchIndices({ client, indices: [state.currentAlias, state.versionAlias] }), LEGACY_SET_WRITE_BLOCK: (state: LegacySetWriteBlockState) => Actions.setWriteBlock({ client, index: state.legacyIndex }), LEGACY_CREATE_REINDEX_TARGET: (state: LegacyCreateReindexTargetState) =>