Skip to content

Commit d9cd17b

Browse files
Adding model versions for all remaining so types without model versions (#195500)
Resolves #184618 ## Summary Adds v1 schemas for all remaining Response Ops owned saved object types: * `connector_token` * `api_key_pending_invalidation` * `maintenance-window` * `rules-settings` ## To Verify 1. Run ES and Kibana on `main` and create saved objects for each of the above types: a. Create an OAuth ServiceNow ITOM connector to create a `connector_token` saved object b. Create a rule, let it run, and then delete the rule. This will create an `api_key_pending_invalidation` SO and 2 `rules-settings` SOs c. Create some maintenance windows, both with and without filters 2. Keep ES running and switch to this branch and restart Kibana. Then verify you can read and modify the existing SOs with no errors a. Test the ServiceNow ITOM connector, which should read the `connector_token` SO b. Modify the rules settings and then run a rule to ensure they're loaded with no errors c. Load the maintenance window UI and edit a MW Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 5fbec1f commit d9cd17b

17 files changed

Lines changed: 283 additions & 7 deletions

File tree

src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
6060
"action_task_params": "b50cb5c8a493881474918e8d4985e61374ca4c30",
6161
"ad_hoc_run_params": "d4e3c5c794151d0a4f5c71e886b2aa638da73ad2",
6262
"alert": "05b07040b12ff45ab642f47464e8a6c903cf7b86",
63-
"api_key_pending_invalidation": "1399e87ca37b3d3a65d269c924eda70726cfe886",
63+
"api_key_pending_invalidation": "8f5554d1984854011b8392d9a6f7ef985bcac03c",
6464
"apm-custom-dashboards": "b67128f78160c288bd7efe25b2da6e2afd5e82fc",
6565
"apm-indices": "8a2d68d415a4b542b26b0d292034a28ffac6fed4",
6666
"apm-server-schema": "58a8c6468edae3d1dc520f0134f59cf3f4fd7eff",
@@ -83,7 +83,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
8383
"cloud-security-posture-settings": "e0f61c68bbb5e4cfa46ce8994fa001e417df51ca",
8484
"config": "179b3e2bc672626aafce3cf92093a113f456af38",
8585
"config-global": "8e8a134a2952df700d7d4ec51abb794bbd4cf6da",
86-
"connector_token": "5a9ac29fe9c740eb114e9c40517245c71706b005",
86+
"connector_token": "79977ea2cb1530ba7e315b95c1b5a524b622a6b3",
8787
"core-usage-stats": "b3c04da317c957741ebcdedfea4524049fdc79ff",
8888
"csp-rule-template": "c151324d5f85178169395eecb12bac6b96064654",
8989
"dashboard": "211e9ca30f5a95d5f3c27b1bf2b58e6cfa0c9ae9",
@@ -131,7 +131,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
131131
"lens": "5cfa2c52b979b4f8df56dd13c477e152183468b9",
132132
"lens-ui-telemetry": "8c47a9e393861f76e268345ecbadfc8a5fb1e0bd",
133133
"links": "1dd432cc94619a513b75cec43660a50be7aadc90",
134-
"maintenance-window": "d893544460abad56ff7a0e25b78f78776dfe10d1",
134+
"maintenance-window": "bf36863f5577c2d22625258bdad906eeb4cccccc",
135135
"map": "76c71023bd198fb6b1163b31bafd926fe2ceb9da",
136136
"metrics-data-source": "81b69dc9830699d9ead5ac8dcb9264612e2a3c89",
137137
"metrics-explorer-view": "98cf395d0e87b89ab63f173eae16735584a8ff42",
@@ -147,7 +147,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
147147
"policy-settings-protection-updates-note": "33924bb246f9e5bcb876109cc83e3c7a28308352",
148148
"query": "501bece68f26fe561286a488eabb1a8ab12f1137",
149149
"risk-engine-configuration": "bab237d09c2e7189dddddcb1b28f19af69755efb",
150-
"rules-settings": "892a2918ebaeba809a612b8d97cec0b07c800b5f",
150+
"rules-settings": "ba57ef1881b3dcbf48fbfb28902d8f74442190b2",
151151
"sample-data-telemetry": "37441b12f5b0159c2d6d5138a494c9f440e950b5",
152152
"search": "0aa6eefb37edd3145be340a8b67779c2ca578b22",
153153
"search-session": "b2fcd840e12a45039ada50b1355faeafa39876d1",

x-pack/plugins/actions/server/saved_objects/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {
1313
import { EncryptedSavedObjectsPluginSetup } from '@kbn/encrypted-saved-objects-plugin/server';
1414
import { getOldestIdleActionTask } from '@kbn/task-manager-plugin/server';
1515
import { ALERTING_CASES_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server';
16-
import { actionTaskParamsModelVersions } from './model_versions';
1716
import { actionMappings, actionTaskParamsMappings, connectorTokenMappings } from './mappings';
1817
import { getActionsMigrations } from './actions_migrations';
1918
import { getActionTaskParamsMigrations } from './action_task_params_migrations';
@@ -26,7 +25,11 @@ import {
2625
ACTION_TASK_PARAMS_SAVED_OBJECT_TYPE,
2726
CONNECTOR_TOKEN_SAVED_OBJECT_TYPE,
2827
} from '../constants/saved_objects';
29-
import { connectorModelVersions } from './model_versions';
28+
import {
29+
actionTaskParamsModelVersions,
30+
connectorModelVersions,
31+
connectorTokenModelVersions,
32+
} from './model_versions';
3033

3134
export function setupSavedObjects(
3235
savedObjects: SavedObjectsServiceSetup,
@@ -121,6 +124,7 @@ export function setupSavedObjects(
121124
management: {
122125
importableAndExportable: false,
123126
},
127+
modelVersions: connectorTokenModelVersions,
124128
});
125129

126130
encryptedSavedObjects.registerType({
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { SavedObjectsModelVersionMap } from '@kbn/core-saved-objects-server';
9+
import { rawConnectorTokenSchemaV1 } from '../schemas/raw_connector_token';
10+
11+
export const connectorTokenModelVersions: SavedObjectsModelVersionMap = {
12+
'1': {
13+
changes: [],
14+
schemas: {
15+
forwardCompatibility: rawConnectorTokenSchemaV1.extends({}, { unknowns: 'ignore' }),
16+
create: rawConnectorTokenSchemaV1,
17+
},
18+
},
19+
};

x-pack/plugins/actions/server/saved_objects/model_versions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
*/
77

88
export { connectorModelVersions } from './connector_model_versions';
9+
export { connectorTokenModelVersions } from './connector_token_model_versions';
910
export { actionTaskParamsModelVersions } from './action_task_params_model_versions';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
export { rawConnectorTokenSchema as rawConnectorTokenSchemaV1 } from './v1';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { schema } from '@kbn/config-schema';
9+
10+
export const rawConnectorTokenSchema = schema.object({
11+
createdAt: schema.string(),
12+
connectorId: schema.string(),
13+
expiresAt: schema.string(),
14+
token: schema.string(),
15+
tokenType: schema.string(),
16+
updatedAt: schema.string(),
17+
});

x-pack/plugins/alerting/server/saved_objects/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ import {
2828
RULES_SETTINGS_SAVED_OBJECT_TYPE,
2929
MAINTENANCE_WINDOW_SAVED_OBJECT_TYPE,
3030
} from '../../common';
31-
import { ruleModelVersions, adHocRunParamsModelVersions } from './model_versions';
31+
import {
32+
adHocRunParamsModelVersions,
33+
apiKeyPendingInvalidationModelVersions,
34+
maintenanceWindowModelVersions,
35+
ruleModelVersions,
36+
rulesSettingsModelVersions,
37+
} from './model_versions';
3238

3339
export const RULE_SAVED_OBJECT_TYPE = 'alert';
3440
export const AD_HOC_RUN_SAVED_OBJECT_TYPE = 'ad_hoc_run_params';
@@ -145,6 +151,7 @@ export function setupSavedObjects(
145151
},
146152
},
147153
},
154+
modelVersions: apiKeyPendingInvalidationModelVersions,
148155
});
149156

150157
savedObjects.registerType({
@@ -153,6 +160,7 @@ export function setupSavedObjects(
153160
hidden: true,
154161
namespaceType: 'single',
155162
mappings: rulesSettingsMappings,
163+
modelVersions: rulesSettingsModelVersions,
156164
});
157165

158166
savedObjects.registerType({
@@ -161,6 +169,7 @@ export function setupSavedObjects(
161169
hidden: true,
162170
namespaceType: 'multiple-isolated',
163171
mappings: maintenanceWindowMappings,
172+
modelVersions: maintenanceWindowModelVersions,
164173
});
165174

166175
savedObjects.registerType({
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { SavedObjectsModelVersionMap } from '@kbn/core-saved-objects-server';
9+
import { rawApiKeyPendingInvalidationSchemaV1 } from '../schemas/raw_api_key_pending_invalidation';
10+
11+
export const apiKeyPendingInvalidationModelVersions: SavedObjectsModelVersionMap = {
12+
'1': {
13+
changes: [],
14+
schemas: {
15+
forwardCompatibility: rawApiKeyPendingInvalidationSchemaV1.extends(
16+
{},
17+
{ unknowns: 'ignore' }
18+
),
19+
create: rawApiKeyPendingInvalidationSchemaV1,
20+
},
21+
},
22+
};

x-pack/plugins/alerting/server/saved_objects/model_versions/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
*/
77

88
export { adHocRunParamsModelVersions } from './ad_hoc_run_params_model_versions';
9+
export { apiKeyPendingInvalidationModelVersions } from './api_key_pending_invalidation_model_versions';
10+
export { maintenanceWindowModelVersions } from './maintenance_window_model_versions';
911
export { ruleModelVersions } from './rule_model_versions';
12+
export { rulesSettingsModelVersions } from './rules_settings_model_versions';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { SavedObjectsModelVersionMap } from '@kbn/core-saved-objects-server';
9+
import { rawMaintenanceWindowSchemaV1 } from '../schemas/raw_maintenance_window';
10+
11+
export const maintenanceWindowModelVersions: SavedObjectsModelVersionMap = {
12+
'1': {
13+
changes: [],
14+
schemas: {
15+
forwardCompatibility: rawMaintenanceWindowSchemaV1.extends({}, { unknowns: 'ignore' }),
16+
create: rawMaintenanceWindowSchemaV1,
17+
},
18+
},
19+
};

0 commit comments

Comments
 (0)