Skip to content

Commit

Permalink
[Response Ops] Remove ephemeral tasks from action and alerting plugins (
Browse files Browse the repository at this point in the history
elastic#197421)

## Summary
Issue: elastic#151461

Removes all reference to ephemeral tasks in the alerting and actions
plugin. As well as unit and E2E tests while maintaining backwards
compatibility for `xpack.alerting.maxEphemeralActionsPerAlert` flag.


### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
3 people authored and hop-dev committed Dec 5, 2024
1 parent d34d439 commit 24e930b
Show file tree
Hide file tree
Showing 29 changed files with 890 additions and 1,385 deletions.
6 changes: 0 additions & 6 deletions docs/settings/alert-action-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,6 @@ For a <<servicenow-action-type,{sn-itsm}>>, <<servicenow-sir-action-type,{sn-sir
[[alert-settings]]
=== Alerting settings

`xpack.alerting.maxEphemeralActionsPerAlert` {ess-icon}::
deprecated:[8.8.0]
Sets the number of actions that will run ephemerally. To use this, enable
ephemeral tasks in task manager first with
<<task-manager-settings,`xpack.task_manager.ephemeral_tasks.enabled`>>

`xpack.alerting.cancelAlertsOnRuleTimeout` {ess-icon}::
Specifies whether to skip writing alerts and scheduling actions if rule
processing was cancelled due to a timeout. Default: `true`. This setting can be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const createActionsClientMock = () => {
getBulk: jest.fn(),
getOAuthAccessToken: jest.fn(),
execute: jest.fn(),
ephemeralEnqueuedExecution: jest.fn(),
bulkEnqueueExecution: jest.fn(),
listTypes: jest.fn(),
isActionTypeEnabled: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const unsecuredSavedObjectsClient = savedObjectsClientMock.create();
const scopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const actionExecutor = actionExecutorMock.create();
const authorization = actionsAuthorizationMock.create();
const ephemeralExecutionEnqueuer = jest.fn();
const bulkExecutionEnqueuer = jest.fn();
const request = httpServerMock.createKibanaRequest();
const auditLogger = auditLoggerMock.create();
Expand Down Expand Up @@ -138,7 +137,6 @@ beforeEach(() => {
kibanaIndices,
inMemoryConnectors: [],
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -613,7 +611,6 @@ describe('create()', () => {
kibanaIndices,
inMemoryConnectors: [],
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -739,7 +736,6 @@ describe('create()', () => {
],

actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -801,7 +797,6 @@ describe('create()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -862,7 +857,6 @@ describe('get()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -899,7 +893,6 @@ describe('get()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -956,7 +949,6 @@ describe('get()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -999,7 +991,6 @@ describe('get()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -1121,7 +1112,6 @@ describe('get()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -1165,7 +1155,6 @@ describe('get()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -1199,7 +1188,6 @@ describe('get()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -1270,7 +1258,6 @@ describe('getBulk()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -1408,7 +1395,6 @@ describe('getBulk()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -1503,7 +1489,6 @@ describe('getBulk()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -1577,7 +1562,6 @@ describe('getBulk()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -1662,7 +1646,6 @@ describe('getOAuthAccessToken()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -2097,7 +2080,6 @@ describe('delete()', () => {
},
],
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -2133,7 +2115,6 @@ describe('delete()', () => {
},
],
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -2653,7 +2634,6 @@ describe('update()', () => {
},
],
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -2696,7 +2676,6 @@ describe('update()', () => {
},
],
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -2782,7 +2761,6 @@ describe('execute()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -2845,7 +2823,6 @@ describe('execute()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -2907,7 +2884,6 @@ describe('execute()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -3180,7 +3156,6 @@ describe('isPreconfigured()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -3230,7 +3205,6 @@ describe('isPreconfigured()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -3282,7 +3256,6 @@ describe('isSystemAction()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -3332,7 +3305,6 @@ describe('isSystemAction()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down
18 changes: 0 additions & 18 deletions x-pack/plugins/actions/server/actions_client/actions_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
Logger,
} from '@kbn/core/server';
import { AuditLogger } from '@kbn/security-plugin/server';
import { RunNowResult } from '@kbn/task-manager-plugin/server';
import { IEventLogClient } from '@kbn/event-log-plugin/server';
import { KueryNode } from '@kbn/es-query';
import { Connector, ConnectorWithExtraFindData } from '../application/connector/types';
Expand Down Expand Up @@ -46,7 +45,6 @@ import {
} from '../types';
import { PreconfiguredActionDisabledModificationError } from '../lib/errors/preconfigured_action_disabled_modification';
import {
ExecutionEnqueuer,
ExecuteOptions as EnqueueExecutionOptions,
BulkExecutionEnqueuer,
ExecutionResponse,
Expand Down Expand Up @@ -92,7 +90,6 @@ export interface ConstructorOptions {
unsecuredSavedObjectsClient: SavedObjectsClientContract;
inMemoryConnectors: InMemoryConnector[];
actionExecutor: ActionExecutorContract;
ephemeralExecutionEnqueuer: ExecutionEnqueuer<RunNowResult>;
bulkExecutionEnqueuer: BulkExecutionEnqueuer<ExecutionResponse>;
request: KibanaRequest;
authorization: ActionsAuthorization;
Expand All @@ -112,7 +109,6 @@ export interface ActionsClientContext {
actionExecutor: ActionExecutorContract;
request: KibanaRequest;
authorization: ActionsAuthorization;
ephemeralExecutionEnqueuer: ExecutionEnqueuer<RunNowResult>;
bulkExecutionEnqueuer: BulkExecutionEnqueuer<ExecutionResponse>;
auditLogger?: AuditLogger;
usageCounter?: UsageCounter;
Expand All @@ -131,7 +127,6 @@ export class ActionsClient {
unsecuredSavedObjectsClient,
inMemoryConnectors,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization,
Expand All @@ -148,7 +143,6 @@ export class ActionsClient {
kibanaIndices,
inMemoryConnectors,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization,
Expand Down Expand Up @@ -504,18 +498,6 @@ export class ActionsClient {
return this.context.bulkExecutionEnqueuer(this.context.unsecuredSavedObjectsClient, options);
}

public async ephemeralEnqueuedExecution(options: EnqueueExecutionOptions): Promise<RunNowResult> {
await this.context.authorization.ensureAuthorized({
operation: 'execute',
actionTypeId: options.actionTypeId,
});

return this.context.ephemeralExecutionEnqueuer(
this.context.unsecuredSavedObjectsClient,
options
);
}

public async listTypes({
featureId,
includeSystemActionTypes = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const unsecuredSavedObjectsClient = savedObjectsClientMock.create();
const scopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const actionExecutor = actionExecutorMock.create();
const authorization = actionsAuthorizationMock.create();
const ephemeralExecutionEnqueuer = jest.fn();
const bulkExecutionEnqueuer = jest.fn();
const request = httpServerMock.createKibanaRequest();
const auditLogger = auditLoggerMock.create();
Expand Down Expand Up @@ -131,7 +130,6 @@ beforeEach(() => {
kibanaIndices,
inMemoryConnectors: [],
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const unsecuredSavedObjectsClient = savedObjectsClientMock.create();
const scopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const actionExecutor = actionExecutorMock.create();
const authorization = actionsAuthorizationMock.create();
const ephemeralExecutionEnqueuer = jest.fn();
const bulkExecutionEnqueuer = jest.fn();
const request = httpServerMock.createKibanaRequest();
const auditLogger = auditLoggerMock.create();
Expand All @@ -78,7 +77,6 @@ describe('getAll()', () => {
kibanaIndices,
inMemoryConnectors: [],
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -134,7 +132,6 @@ describe('getAll()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -279,7 +276,6 @@ describe('getAll()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -382,7 +378,6 @@ describe('getAll()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -487,7 +482,6 @@ describe('getAll()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -579,7 +573,6 @@ describe('getAll()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -613,7 +606,6 @@ describe('getAll()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down Expand Up @@ -690,7 +682,6 @@ describe('getAll()', () => {
scopedClusterClient,
kibanaIndices,
actionExecutor,
ephemeralExecutionEnqueuer,
bulkExecutionEnqueuer,
request,
authorization: authorization as unknown as ActionsAuthorization,
Expand Down
Loading

0 comments on commit 24e930b

Please sign in to comment.