[APM] Ensure Saved Objects are versionable (#159881)

This commit is contained in:
Dario Gieselaar 2023-06-20 18:37:58 +02:00 committed by GitHub
parent 18c801f221
commit 85ba9e92fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 5 deletions

View file

@ -59,10 +59,10 @@ describe('checking migration metadata changes on all registered SO types', () =>
"action_task_params": "96e27e7f4e8273ffcd87060221e2b75e81912dd5",
"alert": "dc710bc17dfc98a9a703d388569abccce5f8bf07",
"api_key_pending_invalidation": "1399e87ca37b3d3a65d269c924eda70726cfe886",
"apm-indices": "9b550bac232e057ec25585e5cb0b5fa08b88f7dc",
"apm-server-schema": "0012e7afc8dcaf7e0180443a3f105ed461c610a2",
"apm-service-group": "ef3128df3fc95612f141198ae9ef922b5cb6cd04",
"apm-telemetry": "ff679c0ecceff161fd16189150dca256d0904055",
"apm-indices": "8a2d68d415a4b542b26b0d292034a28ffac6fed4",
"apm-server-schema": "58a8c6468edae3d1dc520f0134f59cf3f4fd7eff",
"apm-service-group": "66dfc1ddd40bad8f693c873bf6002ca30079a4ae",
"apm-telemetry": "4df255b8b022f5d160687db736b9abcd6ab173fe",
"app_search_telemetry": "36234f19573ad397ac30197c45ac219921cc3106",
"application_usage_daily": "20142d23fe5d05ba22b4bc46614d99883bc488f0",
"application_usage_totals": "a29ab014edc20382b9ce22ede221b18cee5d93a6",

View file

@ -7,6 +7,7 @@
import { SavedObjectsType } from '@kbn/core/server';
import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';
import { updateApmOssIndexPaths } from './migrations/update_apm_oss_index_paths';
export interface APMIndices {
@ -36,6 +37,25 @@ export const apmIndices: SavedObjectsType = {
defaultMessage: 'APM Settings - Index',
}),
},
modelVersions: {
'1': {
changes: [],
schemas: {
create: schema.object({
apmIndices: schema.maybe(
schema.object({
error: schema.maybe(schema.string()),
onboarding: schema.maybe(schema.string()),
span: schema.maybe(schema.string()),
transaction: schema.maybe(schema.string()),
metric: schema.maybe(schema.string()),
})
),
isSpaceAware: schema.maybe(schema.boolean()),
}),
},
},
},
migrations: {
'7.16.0': (doc) => {
const attributes = updateApmOssIndexPaths(doc.attributes);

View file

@ -7,6 +7,7 @@
import { SavedObjectsType } from '@kbn/core/server';
import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';
import { APM_SERVER_SCHEMA_SAVED_OBJECT_TYPE } from '../../common/apm_saved_object_constants';
export const apmServerSettings: SavedObjectsType = {
@ -29,4 +30,14 @@ export const apmServerSettings: SavedObjectsType = {
defaultMessage: 'APM Server Schema - Index',
}),
},
modelVersions: {
'1': {
changes: [],
schemas: {
create: schema.object({
schemaJson: schema.string(),
}),
},
},
},
};

View file

@ -8,6 +8,7 @@
import { SavedObjectsType } from '@kbn/core/server';
import { i18n } from '@kbn/i18n';
import type { SavedObjectMigrationFn } from '@kbn/core/server';
import { schema } from '@kbn/config-schema';
import { APM_SERVICE_GROUP_SAVED_OBJECT_TYPE } from '../../common/service_groups';
interface ApmServiceGroupsPre850 {
@ -58,6 +59,19 @@ export const apmServiceGroups: SavedObjectsType = {
defaultMessage: 'APM Service Groups',
}),
},
modelVersions: {
'1': {
changes: [],
schemas: {
create: schema.object({
groupName: schema.string(),
kuery: schema.string(),
description: schema.maybe(schema.string()),
color: schema.maybe(schema.string()),
}),
},
},
},
migrations: {
'8.5.0': migrateApmServiceGroups850,
},

View file

@ -6,6 +6,7 @@
*/
import { SavedObjectsType } from '@kbn/core/server';
import { schema } from '@kbn/config-schema';
import { APM_TELEMETRY_SAVED_OBJECT_ID } from '../../common/apm_saved_object_constants';
export const apmTelemetry: SavedObjectsType = {
@ -16,4 +17,12 @@ export const apmTelemetry: SavedObjectsType = {
dynamic: false,
properties: {},
},
modelVersions: {
'1': {
changes: [],
schemas: {
create: schema.object({}, { unknowns: 'allow' }),
},
},
},
};

View file

@ -36,6 +36,7 @@ export default function featureControlsTests({ getService }: FtrProviderContext)
url: string;
method?: 'get' | 'post' | 'delete' | 'put';
body?: any;
headers?: Record<string, string>;
};
expectForbidden: (result: any) => void;
expectResponse: (result: any) => void;
@ -160,6 +161,9 @@ export default function featureControlsTests({ getService }: FtrProviderContext)
method: 'post',
url: `/api/apm/settings/agent-configuration/search`,
body: { service: { name: 'test-service' }, etag: 'abc' },
headers: {
'elastic-api-version': '2023-10-31',
},
},
expectForbidden: expect403,
expectResponse: expect200,
@ -203,7 +207,7 @@ export default function featureControlsTests({ getService }: FtrProviderContext)
};
async function executeAsUser(
{ method = 'get', url, body }: Endpoint['req'],
{ method = 'get', url, body, headers }: Endpoint['req'],
username: string,
password: string,
spaceId?: string
@ -220,6 +224,7 @@ export default function featureControlsTests({ getService }: FtrProviderContext)
return await request
.auth(username, password)
.set('kbn-xsrf', 'foo')
.set(headers ?? {})
.then((response: any) => ({ error: undefined, response }))
.catch((error: any) => ({ error, response: undefined }));
}