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

Split .kibana system index into multiple indices #154444

Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
29 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
14e9f8e
Relocate 'cases' saved objects to '.kibana_cases' index
gsoldevila Apr 5, 2023
03bdb74
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Apr 5, 2023
05dea55
Fix integration tests
gsoldevila Apr 6, 2023
3e3d4b9
Make `indexPattern: string` again
gsoldevila Apr 6, 2023
c895981
Merge branch 'main' into kbn-104081-split-multiple-indices-logic
gsoldevila Apr 6, 2023
6c10618
Merge branch 'kbn-104081-split-multiple-indices-logic' into kbn-10408…
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
d1c1055
Merge branch 'kbn-104081-split-multiple-indices-logic' into kbn-10408…
gsoldevila Apr 11, 2023
6483764
Fix incorrect call to esClient.get(); use .kibana_cases index
gsoldevila Apr 11, 2023
2046c27
Update mappings with .kibana_ to fake that reindex split is complete
rudolf 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
ce58e44
Merge branch 'kbn-104081-split-multiple-indices-logic' into kbn-10408…
gsoldevila Apr 11, 2023
288c4b4
Fix outdated integration test
gsoldevila Apr 11, 2023
342c400
remove unused var
pgayvallet Apr 12, 2023
d0bb843
Merge remote-tracking branch 'upstream/main' into kbn-104081-split-mu…
pgayvallet Apr 12, 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