forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Upgrade Assistant] Server-side batch reindexing (elastic#58598) (ela…
…stic#59532) * Added server side logic for handling batch reindex * Remove literal string interpolation from translation * Refactor return value of batch endpoint "sucesses" does not communicate accurately what has happened. "started" more closely reflects what has happened. * First iteration of batch queues * Single queue Changed the batchqueues implementation to only using a single queue - since there is only one ES that it is interacting with. Before continuing with this work, just making sure that these pre- cautions are necessary! * Clean up old batch queue implementation * Slight refactor * Revert batch queues implementation * Introduction of QueueSettings Queue settings can be set on a reindex operation and set a timemstamp value on the reindex operation for the scheduler to use down the line for ordering operations and running them in series * Updated worker logic to handle items in queue in series * Refactor /batch endpoint response to "enqueued" not "started" * Fixed jest tests * Refactor worker refresh operations for readability Created a new file op_utils where logic repsonsible for sorting and ordering reindex operation saved objects is. * Add batch API integration test Also assert that reindexing is happening in the expected order * Added a new endpoint: GET batch/queue This allows users of the API to see what the current queue state is for visibility. Using the queue endpoint int he API integration tests for batch too. * Reset the queuedAt timestamp on resume If a reindexOperation is being resumed and put in a queue we also need to reset the queuedAt timestamp to respect the new batch queue ordering. * Fix jest test Added 'undefined' as the second optional param to resumeIndexOperation call. Co-authored-by: Elastic Machine <[email protected]> # Conflicts: # x-pack/plugins/upgrade_assistant/server/lib/reindexing/error.ts # x-pack/plugins/upgrade_assistant/server/lib/reindexing/error_symbols.ts # x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts # x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.test.ts # x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts # x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
769d08a
commit f7595fd
Showing
15 changed files
with
548 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
x-pack/plugins/upgrade_assistant/server/lib/reindexing/op_utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { flow } from 'fp-ts/lib/function'; | ||
import { ReindexSavedObject } from '../../../common/types'; | ||
|
||
export interface SortedReindexSavedObjects { | ||
/** | ||
* Reindex objects sorted into this array represent Elasticsearch reindex tasks that | ||
* have no inherent order and are considered to be processed in parallel. | ||
*/ | ||
parallel: ReindexSavedObject[]; | ||
|
||
/** | ||
* Reindex objects sorted into this array represent Elasticsearch reindex tasks that | ||
* are consistently ordered (see {@link orderQueuedReindexOperations}) and should be | ||
* processed in order. | ||
*/ | ||
queue: ReindexSavedObject[]; | ||
} | ||
|
||
const sortReindexOperations = (ops: ReindexSavedObject[]): SortedReindexSavedObjects => { | ||
const parallel: ReindexSavedObject[] = []; | ||
const queue: ReindexSavedObject[] = []; | ||
for (const op of ops) { | ||
if (op.attributes.reindexOptions?.queueSettings) { | ||
queue.push(op); | ||
} else { | ||
parallel.push(op); | ||
} | ||
} | ||
|
||
return { | ||
parallel, | ||
queue, | ||
}; | ||
}; | ||
const orderQueuedReindexOperations = ({ | ||
parallel, | ||
queue, | ||
}: SortedReindexSavedObjects): SortedReindexSavedObjects => ({ | ||
parallel, | ||
// Sort asc | ||
queue: queue.sort( | ||
(a, b) => | ||
a.attributes.reindexOptions!.queueSettings!.queuedAt - | ||
b.attributes.reindexOptions!.queueSettings!.queuedAt | ||
), | ||
}); | ||
|
||
export const sortAndOrderReindexOperations = flow( | ||
sortReindexOperations, | ||
orderQueuedReindexOperations | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { createReindexWorker, registerReindexIndicesRoutes } from './reindex_indices'; |
Oops, something went wrong.