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

[Actions] Fixed ad-hoc actions tasks remain as "running" when they timeout by adding cancellation support #120853

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3648196
[Actions] Fixed ad-hoc actions tasks remain as "running" when they ti…
YulNaumenko Dec 8, 2021
17719f8
fixed test
YulNaumenko Dec 8, 2021
77582db
fixed tests
YulNaumenko Dec 9, 2021
4422f01
fixed test
YulNaumenko Dec 11, 2021
0051926
removed test data
YulNaumenko Dec 11, 2021
1edd2e5
Merge branch 'main' into alerting-actions-task-canceletion
kibanamachine Dec 12, 2021
c4c5e77
fixed typechecks
YulNaumenko Dec 13, 2021
809ca3f
Merge branch 'alerting-actions-task-canceletion' of https://github.co…
YulNaumenko Dec 13, 2021
202ffce
fixed typechecks
YulNaumenko Dec 13, 2021
41a99b5
fixed typechecks
YulNaumenko Dec 13, 2021
4c673bd
fixed tests
YulNaumenko Dec 13, 2021
0419670
fixed typechecks
YulNaumenko Dec 14, 2021
9586c9d
Merge branch 'main' into alerting-actions-task-canceletion
kibanamachine Dec 15, 2021
1bee5c5
fixed tests
YulNaumenko Dec 16, 2021
d01d993
Merge branch 'alerting-actions-task-canceletion' of github.com:YulNau…
YulNaumenko Dec 16, 2021
b99fe00
fixed typechecks
YulNaumenko Dec 16, 2021
c09a7dc
Merge branch 'main' into alerting-actions-task-canceletion
kibanamachine Dec 16, 2021
dd79de3
fixed test
YulNaumenko Dec 16, 2021
54dca9c
fixed tests
YulNaumenko Dec 16, 2021
bd0951e
Merge branch 'main' into alerting-actions-task-canceletion
kibanamachine Dec 20, 2021
9ccda95
Merge branch 'main' into alerting-actions-task-canceletion
kibanamachine Jan 4, 2022
fc50674
fixed tests
YulNaumenko Jan 4, 2022
742a7e1
Merge branch 'main' into alerting-actions-task-canceletion
kibanamachine Jan 5, 2022
eb90126
Merge branch 'main' into alerting-actions-task-canceletion
kibanamachine Jan 7, 2022
28fa7d8
Merge branch 'main' into alerting-actions-task-canceletion
kibanamachine Jan 16, 2022
ad1a0b4
Merge remote-tracking branch 'upstream/main' into alerting-actions-ta…
YulNaumenko Jan 16, 2022
599d366
Merge branch 'alerting-actions-task-canceletion' of https://github.co…
YulNaumenko Jan 16, 2022
72c3d3e
changed unit tests
YulNaumenko Jan 17, 2022
5dfe01c
fixed tests
YulNaumenko Jan 18, 2022
31fad53
fixed jest tests
YulNaumenko Jan 18, 2022
d882a32
Merge remote-tracking branch 'upstream/main' into alerting-actions-ta…
YulNaumenko Jan 18, 2022
4f346b2
fixed typechecks
YulNaumenko Jan 19, 2022
3cfb266
Merge branch 'main' into alerting-actions-task-canceletion
kibanamachine Jan 19, 2022
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
11 changes: 11 additions & 0 deletions x-pack/plugins/actions/server/lib/task_runner_factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ test('cleans up action_task_params object', async () => {
expect(services.savedObjectsClient.delete).toHaveBeenCalledWith('action_task_params', '3');
});

test('task runner should implement CancellableTask cancel method with logging warning message', async () => {
const taskRunner = taskRunnerFactory.create({
taskInstance: mockedTaskInstance,
});

await taskRunner.cancel();
expect(taskRunnerFactoryInitializerParams.logger.warn).toHaveBeenCalledWith(
`Action task with params '{"actionTaskParamsId":"3","spaceId":"test"}' was cancelled due to the timeout.`
);
});

test('runs successfully when cleanup fails and logs the error', async () => {
const taskRunner = taskRunnerFactory.create({
taskInstance: mockedTaskInstance,
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/actions/server/lib/task_runner_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { pick } from 'lodash';
import type { Request } from '@hapi/hapi';
import { pipe } from 'fp-ts/lib/pipeable';
import { map, fromNullable, getOrElse } from 'fp-ts/lib/Option';
import stringify from 'json-stable-stringify';
import { addSpaceIdToPath } from '../../../spaces/server';
import {
Logger,
Expand Down Expand Up @@ -193,6 +194,14 @@ export class TaskRunnerFactory {
}
}
},
cancel: async () => {
logger.warn(
`Action task with params '${stringify(
YulNaumenko marked this conversation as resolved.
Show resolved Hide resolved
taskInstance.params as ActionTaskExecutorParams
)}' was cancelled due to the timeout.`
);
return { state: {} };
},
};
}
}
Expand Down