Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dot-kibana-split] Allow relocating SO to different indices during migration #154846

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
050034d
Allow relocating SO to different indices during migration
gsoldevila Mar 31, 2023
30cffcb
Revert changes in ES archiver
gsoldevila Mar 31, 2023
dffba15
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Mar 31, 2023
75dcf23
Revert correctly ^^
gsoldevila Mar 31, 2023
c0f8249
Fix failing integration tests, add a new one to test the split
gsoldevila Apr 3, 2023
cd0f5d0
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 3, 2023
942c026
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 4, 2023
dfc8045
Define MAIN_SAVED_OBJECT_INDEX in @kbn/core-saved-objects-server
gsoldevila Apr 4, 2023
279a2ed
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 4, 2023
59c2908
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 5, 2023
c895981
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 6, 2023
be3541e
Fix typo: involed => involved
gsoldevila Apr 6, 2023
087742d
Address some PR remarks
gsoldevila Apr 11, 2023
fa57995
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 11, 2023
4efdb10
Address some of the PR remarks
gsoldevila Apr 11, 2023
9725176
Take into account targetMappings._meta when merging
gsoldevila Apr 11, 2023
ee3e52d
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 11, 2023
5eb4140
Address PR remarks
gsoldevila Apr 12, 2023
a34bc92
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 12, 2023
3ebcd3b
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 12, 2023
3b5fefb
Merge branch 'dot-kibana-split' into kbn-104081-split-multiple-indice…
gsoldevila Apr 13, 2023
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 @@ -22,8 +22,9 @@ import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-m
import { kibanaMigratorMock } from '../mocks';
import { SavedObjectsSerializer } from '@kbn/core-saved-objects-base-server-internal';
import {
ISavedObjectsEncryptionExtension,
SavedObjectsRawDocSource,
MAIN_SAVED_OBJECT_INDEX,
type ISavedObjectsEncryptionExtension,
type SavedObjectsRawDocSource,
} from '@kbn/core-saved-objects-server';
import {
bulkCreateSuccess,
Expand All @@ -41,8 +42,8 @@ import {
mockVersion,
mockVersionProps,
MULTI_NAMESPACE_ENCRYPTED_TYPE,
TypeIdTuple,
updateSuccess,
type TypeIdTuple,
} from '../test_helpers/repository.test.common';
import { savedObjectsExtensionsMock } from '../mocks/saved_objects_extensions.mock';

Expand Down Expand Up @@ -633,7 +634,7 @@ describe('SavedObjectsRepository Encryption Extension', () => {
total: 2,
hits: [
{
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
_id: `${space ? `${space}:` : ''}${encryptedSO.type}:${encryptedSO.id}`,
_score: 1,
...mockVersionProps,
Expand All @@ -643,7 +644,7 @@ describe('SavedObjectsRepository Encryption Extension', () => {
},
},
{
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
_id: `${space ? `${space}:` : ''}index-pattern:logstash-*`,
_score: 2,
...mockVersionProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ import type {
SavedObjectsBulkDeleteObject,
SavedObjectsBulkDeleteOptions,
} from '@kbn/core-saved-objects-api-server';
import type {
SavedObjectsRawDoc,
SavedObjectsRawDocSource,
SavedObjectUnsanitizedDoc,
SavedObject,
SavedObjectReference,
BulkResolveError,
import {
type SavedObjectsRawDoc,
type SavedObjectsRawDocSource,
type SavedObjectUnsanitizedDoc,
type SavedObject,
type SavedObjectReference,
type BulkResolveError,
MAIN_SAVED_OBJECT_INDEX,
} from '@kbn/core-saved-objects-server';
import { ALL_NAMESPACES_STRING } from '@kbn/core-saved-objects-utils-server';
import { SavedObjectsErrorHelpers } from '@kbn/core-saved-objects-server';
Expand Down Expand Up @@ -4115,7 +4116,7 @@ describe('SavedObjectsRepository', () => {
body: {
_id: params.id,
...mockVersionProps,
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
get: {
found: true,
_source: {
Expand Down Expand Up @@ -4419,7 +4420,7 @@ describe('SavedObjectsRepository', () => {
body: {
_id: params.id,
...mockVersionProps,
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
get: {
found: true,
_source: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { schema } from '@kbn/config-schema';
import { loggerMock } from '@kbn/logging-mocks';
import { Payload } from 'elastic-apm-node';
import type {
AuthorizationTypeEntry,
AuthorizeAndRedactMultiNamespaceReferencesParams,
CheckAuthorizationResult,
ISavedObjectsSecurityExtension,
SavedObjectsMappingProperties,
SavedObjectsRawDocSource,
SavedObjectsType,
SavedObjectsTypeMappingDefinition,
SavedObject,
SavedObjectReference,
AuthorizeFindParams,
import type { Payload } from 'elastic-apm-node';
import {
type AuthorizationTypeEntry,
type AuthorizeAndRedactMultiNamespaceReferencesParams,
type CheckAuthorizationResult,
type ISavedObjectsSecurityExtension,
type SavedObjectsMappingProperties,
type SavedObjectsRawDocSource,
type SavedObjectsType,
type SavedObjectsTypeMappingDefinition,
type SavedObject,
type SavedObjectReference,
type AuthorizeFindParams,
MAIN_SAVED_OBJECT_INDEX,
} from '@kbn/core-saved-objects-server';
import type {
SavedObjectsBaseOptions,
Expand All @@ -47,9 +48,9 @@ import {
} from '@kbn/core-elasticsearch-client-server-mocks';
import { DocumentMigrator } from '@kbn/core-saved-objects-migration-server-internal';
import {
AuthorizeAndRedactInternalBulkResolveParams,
GetFindRedactTypeMapParams,
AuthorizationTypeMap,
type AuthorizeAndRedactInternalBulkResolveParams,
type GetFindRedactTypeMapParams,
type AuthorizationTypeMap,
SavedObjectsErrorHelpers,
} from '@kbn/core-saved-objects-server';
import { mockGetSearchDsl } from '../lib/repository.test.mock';
Expand Down Expand Up @@ -592,8 +593,6 @@ export const getMockBulkCreateResponse = (
items: objects.map(
({ type, id, originId, attributes, references, migrationVersion, typeMigrationVersion }) => ({
create: {
// status: 1,
// _index: '.kibana',
_id: `${namespace ? `${namespace}:` : ''}${type}:${id}`,
_source: {
[type]: attributes,
Expand Down Expand Up @@ -714,7 +713,7 @@ export const generateIndexPatternSearchResults = (namespace?: string) => {
total: 4,
hits: [
{
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
_id: `${namespace ? `${namespace}:` : ''}index-pattern:logstash-*`,
_score: 1,
...mockVersionProps,
Expand All @@ -731,7 +730,7 @@ export const generateIndexPatternSearchResults = (namespace?: string) => {
},
},
{
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
_id: `${namespace ? `${namespace}:` : ''}config:6.0.0-alpha1`,
_score: 2,
...mockVersionProps,
Expand All @@ -746,7 +745,7 @@ export const generateIndexPatternSearchResults = (namespace?: string) => {
},
},
{
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
_id: `${namespace ? `${namespace}:` : ''}index-pattern:stocks-*`,
_score: 3,
...mockVersionProps,
Expand All @@ -762,7 +761,7 @@ export const generateIndexPatternSearchResults = (namespace?: string) => {
},
},
{
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
_id: `${NAMESPACE_AGNOSTIC_TYPE}:something`,
_score: 4,
...mockVersionProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
getTypes,
type IndexMapping,
type IndexMappingMeta,
type IndexTypesMap,
type SavedObjectsTypeMappingDefinitions,
type IndexMappingMigrationStateMeta,
} from './src/mappings';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export type {
SavedObjectsTypeMappingDefinitions,
IndexMappingMeta,
IndexMapping,
IndexTypesMap,
IndexMappingMigrationStateMeta,
} from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export interface IndexMapping {
_meta?: IndexMappingMeta;
}

/** @internal */
export type IndexTypesMap = Record<string, string[]>;

/** @internal */
export interface IndexMappingMeta {
/**
Expand All @@ -65,6 +68,12 @@ export interface IndexMappingMeta {
* @remark: Only defined for indices using the v2 migration algorithm.
*/
migrationMappingPropertyHashes?: { [k: string]: string };
/**
* A map that tells what are the SO types stored in each index
*
* @remark: Only defined for indices using the v2 migration algorithm.
*/
indexTypesMap?: IndexTypesMap;
/**
* The current model versions of the mapping of the index.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export type MigrationStatus =
/** @internal */
export type MigrationResult =
| { status: 'skipped' }
| { status: 'patched' }
| {
status: 'patched';
destIndex: string;
elapsedMs: number;
}
| {
status: 'migrated';
destIndex: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
* Side Public License, v 1.
*/

import { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
import {
type ISavedObjectTypeRegistry,
MAIN_SAVED_OBJECT_INDEX,
} from '@kbn/core-saved-objects-server';
import { getIndexForType } from './get_index_for_type';

const createTypeRegistry = () => {
Expand All @@ -17,7 +20,7 @@ const createTypeRegistry = () => {

describe('getIndexForType', () => {
const kibanaVersion = '8.0.0';
const defaultIndex = '.kibana';
const defaultIndex = MAIN_SAVED_OBJECT_INDEX;
let typeRegistry: ReturnType<typeof createTypeRegistry>;

beforeEach(() => {
Expand Down
Loading