diff --git a/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts b/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts index aaec0b177197a..3fe15fa1671f1 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts +++ b/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts @@ -109,10 +109,6 @@ describe('reindexService', () => { allow_restricted_indices: true, privileges: ['all'], }, - { - names: ['.tasks'], - privileges: ['read'], - }, ], }, }); @@ -139,10 +135,6 @@ describe('reindexService', () => { allow_restricted_indices: true, privileges: ['all'], }, - { - names: ['.tasks'], - privileges: ['read'], - }, ], }, }); diff --git a/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.ts b/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.ts index 5193c3d4dd86e..6767cb3d500eb 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.ts +++ b/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.ts @@ -523,10 +523,6 @@ export const reindexServiceFactory = ( allow_restricted_indices: true, privileges: ['all'], }, - { - names: ['.tasks'], - privileges: ['read'], - }, ], }, }); diff --git a/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/batch_reindex_indices.test.ts b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/batch_reindex_indices.test.ts index 21c88aea907ea..65a1a90758ebf 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/batch_reindex_indices.test.ts +++ b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/batch_reindex_indices.test.ts @@ -62,6 +62,9 @@ describe('reindex API', () => { licensing: licensingMock.createSetup(), lib: { handleEsError }, getSecurityPlugin: () => securityMock.createStart(), + getSavedObjectsService: () => ({ + createInternalRepository: jest.fn(), + }), }; registerBatchReindexIndicesRoutes(routeDependencies, () => worker); diff --git a/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/batch_reindex_indices.ts b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/batch_reindex_indices.ts index 6abc8d4e40ee7..7bbd0a88f6246 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/batch_reindex_indices.ts +++ b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/batch_reindex_indices.ts @@ -7,6 +7,7 @@ import { schema } from '@kbn/config-schema'; import { errors } from '@elastic/elasticsearch'; +import { SavedObjectsClient } from '@kbn/core/server'; import { API_BASE_PATH } from '../../../common/constants'; import { REINDEX_OP_TYPE, ReindexStatus } from '../../../common/types'; @@ -26,6 +27,7 @@ export function registerBatchReindexIndicesRoutes( licensing, log, getSecurityPlugin, + getSavedObjectsService, lib: { handleEsError }, }: RouteDependencies, getWorker: () => ReindexWorker @@ -51,15 +53,14 @@ export function registerBatchReindexIndicesRoutes( versionCheckHandlerWrapper(async ({ core }, request, response) => { const { elasticsearch: { client: esClient }, - savedObjects, } = await core; - const { getClient } = savedObjects; - const callAsCurrentUser = esClient.asCurrentUser; - const reindexActions = reindexActionsFactory( - getClient({ includedHiddenTypes: [REINDEX_OP_TYPE] }), - callAsCurrentUser, - log + + const soClient = new SavedObjectsClient( + getSavedObjectsService().createInternalRepository([REINDEX_OP_TYPE]) ); + + const callAsCurrentUser = esClient.asCurrentUser; + const reindexActions = reindexActionsFactory(soClient, callAsCurrentUser, log); try { const inProgressOps = await reindexActions.findAllByStatus(ReindexStatus.inProgress); const { queue } = sortAndOrderReindexOperations(inProgressOps); @@ -100,10 +101,14 @@ export function registerBatchReindexIndicesRoutes( }, versionCheckHandlerWrapper(async ({ core }, request, response) => { const { - savedObjects: { getClient }, elasticsearch: { client: esClient }, } = await core; const { indexNames } = request.body; + + const soClient = new SavedObjectsClient( + getSavedObjectsService().createInternalRepository([REINDEX_OP_TYPE]) + ); + const results: PostBatchResponse = { enqueued: [], errors: [], @@ -111,7 +116,7 @@ export function registerBatchReindexIndicesRoutes( for (const indexName of indexNames) { try { const result = await reindexHandler({ - savedObjects: getClient({ includedHiddenTypes: [REINDEX_OP_TYPE] }), + savedObjects: soClient, dataClient: esClient, indexName, log, diff --git a/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/reindex_indices.test.ts b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/reindex_indices.test.ts index daf9daedf8b3a..3d504e85f8794 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/reindex_indices.test.ts +++ b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/reindex_indices.test.ts @@ -66,6 +66,9 @@ describe('reindex API', () => { licensing: licensingMock.createSetup(), lib: { handleEsError }, getSecurityPlugin: () => securityMock.createStart(), + getSavedObjectsService: () => ({ + createInternalRepository: jest.fn(), + }), }; registerReindexIndicesRoutes(routeDependencies, () => worker); diff --git a/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts index a241b54d4bf47..a7b6edd6bbf4e 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts +++ b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts @@ -7,6 +7,7 @@ import { schema } from '@kbn/config-schema'; import { errors } from '@elastic/elasticsearch'; +import { SavedObjectsClient } from '@kbn/core/server'; import { API_BASE_PATH } from '../../../common/constants'; import { ReindexStatusResponse, REINDEX_OP_TYPE } from '../../../common/types'; @@ -24,6 +25,7 @@ export function registerReindexIndicesRoutes( licensing, log, getSecurityPlugin, + getSavedObjectsService, lib: { handleEsError }, }: RouteDependencies, getWorker: () => ReindexWorker @@ -52,13 +54,17 @@ export function registerReindexIndicesRoutes( }, versionCheckHandlerWrapper(async ({ core }, request, response) => { const { - savedObjects: { getClient }, elasticsearch: { client: esClient }, } = await core; const { indexName } = request.params; + + const soClient = new SavedObjectsClient( + getSavedObjectsService().createInternalRepository([REINDEX_OP_TYPE]) + ); + try { const result = await reindexHandler({ - savedObjects: getClient({ includedHiddenTypes: [REINDEX_OP_TYPE] }), + savedObjects: soClient, dataClient: esClient, indexName, log, @@ -105,17 +111,16 @@ export function registerReindexIndicesRoutes( }, versionCheckHandlerWrapper(async ({ core }, request, response) => { const { - savedObjects, elasticsearch: { client: esClient }, } = await core; - const { getClient } = savedObjects; const { indexName } = request.params; const asCurrentUser = esClient.asCurrentUser; - const reindexActions = reindexActionsFactory( - getClient({ includedHiddenTypes: [REINDEX_OP_TYPE] }), - asCurrentUser, - log + + const soClient = new SavedObjectsClient( + getSavedObjectsService().createInternalRepository([REINDEX_OP_TYPE]) ); + + const reindexActions = reindexActionsFactory(soClient, asCurrentUser, log); const reindexService = reindexServiceFactory(asCurrentUser, reindexActions, log, licensing); try {