Skip to content
Closed
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 @@ -109,10 +109,6 @@ describe('reindexService', () => {
allow_restricted_indices: true,
privileges: ['all'],
},
{
names: ['.tasks'],
privileges: ['read'],
},
],
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,6 @@ export const reindexServiceFactory = (
allow_restricted_indices: true,
privileges: ['all'],
},
{
names: ['.tasks'],
privileges: ['read'],
},
],
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -26,6 +27,7 @@ export function registerBatchReindexIndicesRoutes(
licensing,
log,
getSecurityPlugin,
getSavedObjectsService,
lib: { handleEsError },
}: RouteDependencies,
getWorker: () => ReindexWorker
Expand All @@ -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);
Expand Down Expand Up @@ -91,18 +93,22 @@ 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: [],
};
for (const indexName of indexNames) {
try {
const result = await reindexHandler({
savedObjects: getClient({ includedHiddenTypes: [REINDEX_OP_TYPE] }),
savedObjects: soClient,
dataClient: esClient,
indexName,
log,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,6 +25,7 @@ export function registerReindexIndicesRoutes(
licensing,
log,
getSecurityPlugin,
getSavedObjectsService,
lib: { handleEsError },
}: RouteDependencies,
getWorker: () => ReindexWorker
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down