Skip to content

Commit 11e3a0b

Browse files
Reapply "[Response Ops][Alerting] Backfill actions schema changes for intermediate release (#204657)
## Summary Redoing [this PR](#203184) which had to be [reverted](#204218). This should not be merged until [this update to the task manager v1 schema](#204413) is released. ## To verify 1. Set `xpack.task_manager.unsafe.exclude_task_types: ['ad_hoc_run-backfill', 'actions:*']` in your Kibana config. 2. Run Kibana on main and create some detection rules that run frequently, with actions. 3. Schedule a manual run for your detection rules. - Because of the config, the `action_task_params` SO and the `ad_hoc_run_task_params` SO will get written but not read yet. 4. Remove the `exclude_task_types` config and "upgrade" to this PR branch and verify that rules continue to run and that the actions are triggered and the manual rule runs go through 5. Re-add the `exclude_task_types` config and let the rule run again to schedule action. Schedule another manual rule run. 6. Remove the `exclude_task_types` config and "downgrade" back to main and verify that rules continue to run, the action gets triggered and manual rule runs go through. Co-authored-by: Elastic Machine <[email protected]>
1 parent 28414ce commit 11e3a0b

File tree

16 files changed

+194
-9
lines changed

16 files changed

+194
-9
lines changed

packages/kbn-check-mappings-update-cli/current_fields.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"actionTypeId",
44
"name"
55
],
6-
"action_task_params": [],
6+
"action_task_params": [
7+
"apiKeyId"
8+
],
79
"ad_hoc_run_params": [
810
"apiKeyId",
911
"createdAt",
@@ -1104,6 +1106,7 @@
11041106
"enabled",
11051107
"ownerId",
11061108
"partition",
1109+
"priority",
11071110
"retryAt",
11081111
"runAt",
11091112
"schedule",

packages/kbn-check-mappings-update-cli/current_mappings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
},
1818
"action_task_params": {
1919
"dynamic": false,
20-
"properties": {}
20+
"properties": {
21+
"apiKeyId": {
22+
"type": "keyword"
23+
}
24+
}
2125
},
2226
"ad_hoc_run_params": {
2327
"dynamic": false,
@@ -3655,6 +3659,9 @@
36553659
"partition": {
36563660
"type": "integer"
36573661
},
3662+
"priority": {
3663+
"type": "integer"
3664+
},
36583665
"retryAt": {
36593666
"type": "date"
36603667
},

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ describe('checking migration metadata changes on all registered SO types', () =>
5757
expect(hashMap).toMatchInlineSnapshot(`
5858
Object {
5959
"action": "0e6fc0b74c7312a8c11ff6b14437b93a997358b8",
60-
"action_task_params": "b50cb5c8a493881474918e8d4985e61374ca4c30",
61-
"ad_hoc_run_params": "d4e3c5c794151d0a4f5c71e886b2aa638da73ad2",
60+
"action_task_params": "2e475d8b62e2de50b77f58cda309efb537e1d543",
61+
"ad_hoc_run_params": "c7419760e878207231c3c8a25ec4d78360e07bf7",
6262
"alert": "556a03378f5ee1c31593c3a37c66b54555ee14ff",
6363
"api_key_pending_invalidation": "8f5554d1984854011b8392d9a6f7ef985bcac03c",
6464
"apm-custom-dashboards": "b67128f78160c288bd7efe25b2da6e2afd5e82fc",
@@ -170,7 +170,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
170170
"synthetics-private-location": "8cecc9e4f39637d2f8244eb7985c0690ceab24be",
171171
"synthetics-privates-locations": "f53d799d5c9bc8454aaa32c6abc99a899b025d5c",
172172
"tag": "e2544392fe6563e215bb677abc8b01c2601ef2dc",
173-
"task": "3c89a7c918d5b896a5f8800f06e9114ad7e7aea3",
173+
"task": "ca8020259e46f713965a754ffae286c02d3cf05d",
174174
"telemetry": "7b00bcf1c7b4f6db1192bb7405a6a63e78b699fd",
175175
"threshold-explorer-view": "175306806f9fc8e13fcc1c8953ec4ba89bda1b70",
176176
"ui-metric": "d227284528fd19904e9d972aea0a13716fc5fe24",

x-pack/platform/plugins/shared/actions/server/saved_objects/mappings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export const actionMappings: SavedObjectsTypeMappingDefinition = {
4040
export const actionTaskParamsMappings: SavedObjectsTypeMappingDefinition = {
4141
dynamic: false,
4242
properties: {
43+
apiKeyId: {
44+
type: 'keyword',
45+
},
4346
// NO NEED TO BE INDEXED
4447
// actionId: {
4548
// type: 'keyword',

x-pack/platform/plugins/shared/actions/server/saved_objects/model_versions/action_task_params_model_versions.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,28 @@
66
*/
77

88
import { SavedObjectsModelVersionMap } from '@kbn/core-saved-objects-server';
9-
import { actionTaskParamsSchemaV1 } from '../schemas/action_task_params';
9+
import { actionTaskParamsSchemaV1, actionTaskParamsSchemaV2 } from '../schemas/action_task_params';
1010

1111
export const actionTaskParamsModelVersions: SavedObjectsModelVersionMap = {
1212
'1': {
1313
changes: [],
1414
schemas: {
15+
forwardCompatibility: actionTaskParamsSchemaV1.extends({}, { unknowns: 'ignore' }),
1516
create: actionTaskParamsSchemaV1,
1617
},
1718
},
19+
'2': {
20+
changes: [
21+
{
22+
type: 'mappings_addition',
23+
addedMappings: {
24+
apiKeyId: { type: 'keyword' },
25+
},
26+
},
27+
],
28+
schemas: {
29+
forwardCompatibility: actionTaskParamsSchemaV2.extends({}, { unknowns: 'ignore' }),
30+
create: actionTaskParamsSchemaV2,
31+
},
32+
},
1833
};

x-pack/platform/plugins/shared/actions/server/saved_objects/schemas/action_task_params/index.ts

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

88
export { actionTaskParamsSchema as actionTaskParamsSchemaV1 } from './v1';
9+
export { actionTaskParamsSchema as actionTaskParamsSchemaV2 } from './v2';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
import { actionTaskParamsSchema as actionTaskParamsSchemaV1 } from './v1';
10+
11+
export const actionTaskParamsSchema = actionTaskParamsSchemaV1.extends({
12+
apiKeyId: schema.maybe(schema.string()),
13+
});

x-pack/platform/plugins/shared/alerting/common/routes/backfill/apis/schedule/schemas/v1.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const scheduleBodySchema = schema.arrayOf(
1515
rule_id: schema.string(),
1616
start: schema.string(),
1717
end: schema.maybe(schema.string()),
18+
run_actions: schema.maybe(schema.boolean()),
1819
},
1920
{
2021
validate({ start, end }) {

x-pack/platform/plugins/shared/alerting/server/saved_objects/model_versions/ad_hoc_run_params_model_versions.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
*/
77

88
import { SavedObjectsModelVersionMap } from '@kbn/core-saved-objects-server';
9-
import { rawAdHocRunParamsSchemaV1 } from '../schemas/raw_ad_hoc_run_params';
9+
import {
10+
rawAdHocRunParamsSchemaV1,
11+
rawAdHocRunParamsSchemaV2,
12+
} from '../schemas/raw_ad_hoc_run_params';
1013

1114
export const adHocRunParamsModelVersions: SavedObjectsModelVersionMap = {
1215
'1': {
@@ -16,4 +19,11 @@ export const adHocRunParamsModelVersions: SavedObjectsModelVersionMap = {
1619
create: rawAdHocRunParamsSchemaV1,
1720
},
1821
},
22+
'2': {
23+
changes: [],
24+
schemas: {
25+
forwardCompatibility: rawAdHocRunParamsSchemaV2.extends({}, { unknowns: 'ignore' }),
26+
create: rawAdHocRunParamsSchemaV2,
27+
},
28+
},
1929
};

x-pack/platform/plugins/shared/alerting/server/saved_objects/schemas/raw_ad_hoc_run_params/index.ts

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

88
export { rawAdHocRunParamsSchema as rawAdHocRunParamsSchemaV1 } from './v1';
9+
export { rawAdHocRunParamsSchema as rawAdHocRunParamsSchemaV2 } from './v2';

0 commit comments

Comments
 (0)