-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the second part of the ZDT migration algorithm (#153031)
## Summary Part of #150309 Follow-up of #152219 Implement the second part of the zero-downtime migration algorithm: the document conversion. ### Schema because a schema is worth a thousand words: <img width="650" alt="Screenshot 2023-03-22 at 08 33 44" src="https://user-images.githubusercontent.com/1532934/226832339-d74d8349-9969-4c51-a5fe-f77558f17b67.png"> ### TODO / notepad - ~check that all types have model versions in INIT~ will do later when we'll start have real types using MVs - [x] Optimize to skip document migration when creating new index - [x] documentsUpdateInit: extract remaining logic to utilities - [x] outdatedDocumentsSearchRead: cleanup corrupted doc logic - [x] outdatedDocumentsSearchTransform: cleanup corrupted doc logic - [x] tests for /zdt/actions/wait_for_delay.ts ? - ~support for coreMigrationVersion~ added as a follow-up in the parent issue - [x] init -> equal -> check if aliasActions is empty --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
23b7137
commit 3ff906d
Showing
102 changed files
with
4,385 additions
and
342 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
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
18 changes: 18 additions & 0 deletions
18
...ore/saved-objects/core-saved-objects-migration-server-internal/src/common/redact_state.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,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { BulkOperationContainer } from '@elastic/elasticsearch/lib/api/types'; | ||
import type { BulkOperation } from '../model/create_batches'; | ||
|
||
export const redactBulkOperationBatches = ( | ||
bulkOperationBatches: BulkOperation[][] | ||
): BulkOperationContainer[][] => { | ||
return bulkOperationBatches.map((batch) => | ||
batch.map((operation) => (Array.isArray(operation) ? operation[0] : operation)) | ||
); | ||
}; |
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
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
17 changes: 17 additions & 0 deletions
17
...e-saved-objects-migration-server-internal/src/zdt/actions/update_index_meta.test.mocks.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,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const updateMappingsMock = jest.fn(); | ||
|
||
jest.doMock('../../actions/update_mappings', () => { | ||
const actual = jest.requireActual('../../actions/update_mappings'); | ||
return { | ||
...actual, | ||
updateMappings: updateMappingsMock, | ||
}; | ||
}); |
50 changes: 50 additions & 0 deletions
50
...ts/core-saved-objects-migration-server-internal/src/zdt/actions/update_index_meta.test.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,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { updateMappingsMock } from './update_index_meta.test.mocks'; | ||
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks'; | ||
import type { IndexMappingMeta } from '@kbn/core-saved-objects-base-server-internal'; | ||
import { updateIndexMeta } from './update_index_meta'; | ||
|
||
describe('updateIndexMeta', () => { | ||
it('calls updateMappings with the correct parameters', () => { | ||
const client = elasticsearchClientMock.createElasticsearchClient(); | ||
const index = '.kibana_1'; | ||
const meta: IndexMappingMeta = { | ||
mappingVersions: { | ||
foo: 1, | ||
bar: 1, | ||
}, | ||
}; | ||
|
||
updateIndexMeta({ client, index, meta }); | ||
|
||
expect(updateMappingsMock).toHaveBeenCalledTimes(1); | ||
expect(updateMappingsMock).toHaveBeenCalledWith({ | ||
client, | ||
index, | ||
mappings: { | ||
properties: {}, | ||
_meta: meta, | ||
}, | ||
}); | ||
}); | ||
|
||
it('returns the response from updateMappings', () => { | ||
const client = elasticsearchClientMock.createElasticsearchClient(); | ||
const index = '.kibana_1'; | ||
const meta: IndexMappingMeta = {}; | ||
|
||
const expected = Symbol(); | ||
updateMappingsMock.mockReturnValue(expected); | ||
|
||
const actual = updateIndexMeta({ client, index, meta }); | ||
|
||
expect(actual).toBe(expected); | ||
}); | ||
}); |
Oops, something went wrong.