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

[Response Ops] Remove ephemeral tasks from action and alerting plugins #197421

Merged
merged 13 commits into from
Dec 2, 2024

Conversation

JiaweiWu
Copy link
Contributor

@JiaweiWu JiaweiWu commented Oct 23, 2024

Summary

Issue: #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.

Deprecates the following configuration settings:

  • xpack.alerting.maxEphemeralActionsPerAlert

No action is required on the user's end as this deprecation is made so if the above settings are defined, kibana will simply do nothing. However their settings will no longer have any effect as ephemeral tasks are now removed.

Checklist

@JiaweiWu JiaweiWu added release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v9.0.0 labels Oct 23, 2024
@JiaweiWu JiaweiWu requested a review from a team as a code owner October 23, 2024 12:16
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@JiaweiWu JiaweiWu added the backport:skip This commit does not require backporting label Oct 23, 2024
Copy link
Contributor

A documentation preview will be available soon.

Request a new doc build by commenting
  • Rebuild this PR: run docs-build
  • Rebuild this PR and all Elastic docs: run docs-build rebuild

run docs-build is much faster than run docs-build rebuild. A rebuild should only be needed in rare situations.

If your PR continues to fail for an unknown reason, the doc build pipeline may be broken. Elastic employees can check the pipeline status here.

@JiaweiWu JiaweiWu changed the title Remove ephemeral tasks from action and alerting plugins [Response Ops] Remove ephemeral tasks from action and alerting plugins Oct 23, 2024
@@ -127,84 +127,6 @@ describe('health check', () => {
);
});

test('renders warning if encryption key is ephemeral', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we probably want to keep this test? i don't think it's related to ephemeral tasks

cacheInterval: schema.number({ defaultValue: DEFAULT_CACHE_INTERVAL_MS }),
}),
},
{ unknowns: 'allow' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Preventing unknowns adds the benefit of users knowing when they have typos and such. Perhaps if we change maxEphemeralActionsPerAlert to a schema.maybe(schema.number()), we won't see it anywhere else (it'll be empty by default now)

@JiaweiWu
Copy link
Contributor Author

Im wondering if we can just remove the cleanup function here: https://github.com/JiaweiWu/kibana/blob/main/x-pack/plugins/actions/server/lib/task_runner_factory.ts#L212

Since the isPersistedActionTask seems to check if the task is an ephemeral task (which is now removed).

@mikecote
Copy link
Contributor

Im wondering if we can just remove the cleanup function here: https://github.com/JiaweiWu/kibana/blob/main/x-pack/plugins/actions/server/lib/task_runner_factory.ts#L212

Since the isPersistedActionTask seems to check if the task is an ephemeral task (which is now removed).

I believe so, ephemeral tasks are not persisted so once users upgrade to the version containing this change, the task runners will only run normal tasks.

@JiaweiWu
Copy link
Contributor Author

Also, let me know if we want to keep these deprecation messages: https://github.com/elastic/kibana/blob/main/x-pack/plugins/alerting/server/index.ts#L87

What's a good way to test that the ephemeral tasks have been removed without affect other code paths? (Aside from existing unit/E2E tests passing)

@mikecote
Copy link
Contributor

Also, let me know if we want to keep these deprecation messages: https://github.com/elastic/kibana/blob/main/x-pack/plugins/alerting/server/index.ts#L87

Given we're switching to becoming a no-op, perhaps we can change the message. Something like The setting "xpack.alerting.maxEphemeralActionsPerAlert" is deprecated and currently ignored by the system. Please remove this setting.

What's a good way to test that the ephemeral tasks have been removed without affect other code paths? (Aside from existing unit/E2E tests passing)

Hmm, I wonder if turning on all the settings that we have as no-op and creating some rules that fire actions. If we see the actions still working, that would be one way to manually verify the changes are working. Thoughts?

Copy link
Contributor

@mikecote mikecote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, I would also update the deprecation message as we discussed in #197421 (comment).

Comment on lines 97 to 100
const bulkScheduleRequest: EnqueueExecutionOptions[] = [];

for (const result of allActionsToScheduleResult) {
await this.runActionAsEphemeralOrAddToBulkScheduleRequest({
enqueueOptions: result.actionToEnqueue,
bulkScheduleRequest,
});
bulkScheduleRequest.push(result.actionToEnqueue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

We can remove bulkScheduleRequest and use allActionsToScheduleResult variable directly now.

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`>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably need a cloud PR to remove them from the allow-list: https://github.com/elastic/cloud/pull/84878

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm ... not sure. I know the allow-list must be used when creating / updating the Kibana yml in the clould admin panels, but when else would it be used? If it gets used at some other time (cluster restart), then potentially it could prevent the restart because of invalid config?

It's fine if it's only used while creating / updating the Kibana yml in the cloud admin panel - presumably the config wouldn't be saveable next time a customer edited it, till they removed the config setting.

Have we done this in the past? I feel like we must have ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's true. I guess we're just ignoring it now if it's set so it doesn't matter if it's still there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should create a PR to label these in comments as deprecated, if we're not sure? Breadcrumbs for future cleanups?

Copy link
Contributor

@mikecote mikecote Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://github.com/elastic/cloud/pull/133738#discussion_r1828211350, we can set a max value as we have to keep it around for deployments running 8.x for a long time.

@@ -362,104 +334,6 @@ describe('Task Runner', () => {
).toHaveBeenCalled();
});

test.each(ephemeralTestParams)(
'actionsPlugin.execute is called per alert alert that is scheduled %s',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we want to keep all of these tests, just not the iteration over the different bulk enqueue execution functions. We want to keep testing that actionsClient.bulkEnqueueExecution is called in these scenarios.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, seems that way ...

@pmuellr
Copy link
Member

pmuellr commented Nov 26, 2024

Code LGTM, but have the same issues as Ying. Will review once the tests have been re-instated ...

@JiaweiWu
Copy link
Contributor Author

JiaweiWu commented Dec 2, 2024

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
actions 316 315 -1
alerting 849 848 -1
total -2
Unknown metric groups

API count

id before after diff
actions 322 321 -1
alerting 881 880 -1
total -2

ESLint disabled line counts

id before after diff
@kbn/test-suites-xpack 722 721 -1
actions 25 24 -1
total -2

Total ESLint disabled count

id before after diff
@kbn/test-suites-xpack 747 746 -1
actions 27 26 -1
total -2

History

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JiaweiWu JiaweiWu merged commit 7e71e5a into elastic:main Dec 2, 2024
8 checks passed
hop-dev pushed a commit to hop-dev/kibana that referenced this pull request Dec 5, 2024
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]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 9, 2024
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]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
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]>
JiaweiWu added a commit that referenced this pull request Dec 13, 2024
## Summary

Resolves: #151463

Removes all reference to ephemeral tasks from the task manager plugin.
As well as unit and E2E tests while maintaining backwards compatibility
for `xpack.task_manager.ephemeral_tasks` flag to no-op if set. This PR
has some dependencies from the PR to remove ephemeral task support from
the alerting and actions plugin
(#197421). So it should be merged
after the other PR.

Deprecates the following configuration settings:

- xpack.task_manager.ephemeral_tasks.enabled
- xpack.task_manager.ephemeral_tasks.request_capacity

The user doesn't have to change anything on their end if they don't wish
to. This deprecation is made so if the above settings are defined,
kibana will simply do nothing.

### 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
@JiaweiWu JiaweiWu added release_note:deprecation and removed release_note:skip Skip the PR/issue when compiling release notes labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:deprecation Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants