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 the .kibana saved objects index into multiple indices #154888

Merged
merged 29 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0c154cb
[dot-kibana-split] Allow relocating SO to different indices during mi…
gsoldevila Apr 13, 2023
e9ee758
Merge branch 'main' into dot-kibana-split
gsoldevila Apr 13, 2023
e13e3cb
[dot-kibana-split] Update dynamic mappings.json to include the `index…
gsoldevila Apr 18, 2023
c7956c6
[dot-kibana-split] Generalise FTR and integration tests to support mu…
gsoldevila Apr 18, 2023
00edae1
[dot-kibana-split] Update ES archiver to support multiple SO indices …
gsoldevila Apr 18, 2023
6c6f2a1
Generalise 7_13_0_transform_failures.test.ts
gsoldevila Apr 18, 2023
1604e8a
Merge remote-tracking branch 'upstream/main' into dot-kibana-split
pgayvallet Apr 19, 2023
181f1d1
updating snapshot
pgayvallet Apr 19, 2023
93e96aa
[dot-kibana-split] Adapt usages of `core.savedObjects.getKibanaIndex`…
pgayvallet Apr 19, 2023
785baa0
[dot-kibana-split] Split rules, alerts and cases saved objects into `…
gsoldevila Apr 19, 2023
bc094dc
[dot-kibana-split] Split ingest types into `.kibana_ingest` (#155130)
pgayvallet Apr 19, 2023
cf8a056
[dot-kibana-split] Split security solution SOs into `.kibana_security…
gsoldevila Apr 19, 2023
b416f1a
[dot-kibana-split] Split analyst experience SOs into `.kibana_analyti…
gsoldevila Apr 19, 2023
f06b439
updating mapping files
pgayvallet Apr 19, 2023
1de1aa2
fixing test message again again again
pgayvallet Apr 19, 2023
70a25fb
fix more security solution FTR helpers & data
pgayvallet Apr 19, 2023
068df54
fix one more test
pgayvallet Apr 20, 2023
5eec2a8
Merge remote-tracking branch 'upstream/main' into dot-kibana-split
pgayvallet Apr 20, 2023
2e91fd3
rename functions
pgayvallet Apr 20, 2023
b1ce437
[dot-kibana-split] Address some PR remarks (#155116)
gsoldevila Apr 20, 2023
18946b3
Merge remote-tracking branch 'upstream/main' into dot-kibana-split
pgayvallet Apr 20, 2023
1409810
update utils description
pgayvallet Apr 21, 2023
a34cc42
[Security Solution] Fix flaky install_prebuilt_rules_from_real_packag…
banderror Apr 21, 2023
31d3fb9
Merge remote-tracking branch 'upstream/main' into dot-kibana-split
pgayvallet Apr 21, 2023
c2c914d
update snapshot due to merge
pgayvallet Apr 21, 2023
b5cb918
fixing added test
pgayvallet Apr 21, 2023
8399cbf
Merge remote-tracking branch 'upstream/main' into dot-kibana-split
pgayvallet Apr 24, 2023
0596fcb
[dot-kibana-split] Misc SO type relocations (#155366)
gsoldevila Apr 24, 2023
c0a25c5
Merge branch 'main' into dot-kibana-split
gsoldevila Apr 25, 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 @@ -245,7 +245,8 @@ export function createPluginSetupContext<TPlugin, TPluginDependencies>(
setSecurityExtension: deps.savedObjects.setSecurityExtension,
setSpacesExtension: deps.savedObjects.setSpacesExtension,
registerType: deps.savedObjects.registerType,
getKibanaIndex: deps.savedObjects.getKibanaIndex,
getDefaultIndex: deps.savedObjects.getDefaultIndex,
getAllIndices: deps.savedObjects.getAllIndices,
},
status: {
core$: deps.status.core$,
Expand Down Expand Up @@ -313,6 +314,10 @@ export function createPluginStartContext<TPlugin, TPluginDependencies>(
createExporter: deps.savedObjects.createExporter,
createImporter: deps.savedObjects.createImporter,
getTypeRegistry: deps.savedObjects.getTypeRegistry,
getDefaultIndex: deps.savedObjects.getDefaultIndex,
getIndexForType: deps.savedObjects.getIndexForType,
getIndicesForTypes: deps.savedObjects.getIndicesForTypes,
getAllIndices: deps.savedObjects.getAllIndices,
},
metrics: {
collectionInterval: deps.metrics.collectionInterval,
Expand Down
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 @@ -4364,7 +4365,7 @@ describe('SavedObjectsRepository', () => {
body: {
_id: params.id,
...mockVersionProps,
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
get: {
found: true,
_source: {
Expand Down Expand Up @@ -4668,7 +4669,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 @@ -601,8 +602,6 @@ export const getMockBulkCreateResponse = (
managed: docManaged,
}) => ({
create: {
// status: 1,
// _index: '.kibana',
_id: `${namespace ? `${namespace}:` : ''}${type}:${id}`,
_source: {
[type]: attributes,
Expand Down Expand Up @@ -726,7 +725,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 @@ -743,7 +742,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 @@ -758,7 +757,7 @@ export const generateIndexPatternSearchResults = (namespace?: string) => {
},
},
{
_index: '.kibana',
_index: MAIN_SAVED_OBJECT_INDEX,
_id: `${namespace ? `${namespace}:` : ''}index-pattern:stocks-*`,
_score: 3,
...mockVersionProps,
Expand All @@ -774,7 +773,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