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 7726dceffb7d5..de94a66f9ed34 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'], - }, ], }, }); 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 31bfe99f34c75..abcbf1897e4b2 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 @@ -457,10 +457,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.ts b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/batch_reindex_indices.ts index 5307299c366d1..f36fb2fed0a97 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 @@ -47,14 +49,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 + + const soClient = new SavedObjectsClient( + getSavedObjectsService().createInternalRepository([REINDEX_OP_TYPE]) ); + + const reindexActions = reindexActionsFactory(soClient, callAsCurrentUser); try { const inProgressOps = await reindexActions.findAllByStatus(ReindexStatus.inProgress); const { queue } = sortAndOrderReindexOperations(inProgressOps); @@ -91,10 +93,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: [], @@ -102,7 +108,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.ts b/x-pack/platform/plugins/private/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts index 9fc8ff6c0a75a..b89f7a89e46f2 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 @@ -48,13 +50,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, @@ -91,16 +97,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 + + const soClient = new SavedObjectsClient( + getSavedObjectsService().createInternalRepository([REINDEX_OP_TYPE]) ); + + const reindexActions = reindexActionsFactory(soClient, asCurrentUser); const reindexService = reindexServiceFactory(asCurrentUser, reindexActions, log, licensing); try {