Skip to content

[Response Ops][Task Manager] Skip API Key Tasks If Security is Disabled #221732

Merged
JiaweiWu merged 4 commits intoelastic:mainfrom
JiaweiWu:issue-216810-skip-api-key-tasks-if-security-disabled
Jun 25, 2025
Merged

[Response Ops][Task Manager] Skip API Key Tasks If Security is Disabled #221732
JiaweiWu merged 4 commits intoelastic:mainfrom
JiaweiWu:issue-216810-skip-api-key-tasks-if-security-disabled

Conversation

@JiaweiWu
Copy link
Contributor

@JiaweiWu JiaweiWu commented May 28, 2025

Summary

Resolves: #216810

This PR uses the licensing plugin to check is security is enabled. If not, we skip adding API keys to tasks that pass in a request object, but still scheduling them.

Checklist

@JiaweiWu JiaweiWu requested review from a team as code owners May 28, 2025 08:16
@ymao1
Copy link
Contributor

ymao1 commented May 28, 2025

Can we resolve the conflicts and ensure CI is green before marking the PR as ready for review please? Thank you!

Comment on lines +17 to +19
"requiredPlugins": [
"licensing"
],
Copy link
Contributor

Choose a reason for hiding this comment

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

For this check, could licensing be an optional dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm following a similar pattern as the alerting plugin to check for if security is enabled: https://github.com/elastic/kibana/blob/main/x-pack/platform/plugins/shared/alerting/kibana.jsonc

Here we have added the licensing plugin a a require plugin, I feel like it's important we determine if security is enabled, is there a downside to adding the licensing plugin to requiredPlugins? Thanks

Copy link
Contributor

@jloleysens jloleysens Jun 24, 2025

Choose a reason for hiding this comment

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

I don't think so per se, but it does keep the task manager plugin a bit less coupled should licensing ever be disabled. Making it an optionalPlugin also means task manager can work without it which I think is a nice property to maintain.

Copy link
Contributor

Choose a reason for hiding this comment

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

Usage would just look more like:

licensing?.license$.subscribe(updateLicenseState);

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Approving to unblock progress, but recommend making licensing optional.

@JiaweiWu
Copy link
Contributor Author

Approving to unblock progress, but recommend making licensing optional.

Ok sounds good, I will make it optional in a future PR, thanks!

@JiaweiWu JiaweiWu added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting v9.1.0 Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// labels Jun 24, 2025
@elasticmachine
Copy link
Contributor

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

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. Works as expected. Left one comment about leaving a log message.


private getSoClientForCreate(options: ApiKeyOptions) {
if (options.request) {
if (options.request && this.getIsSecurityEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we leave an info log when we're trying to schedule a task with a request but security is disabled? something like Trying to schedule task ${task.id} with user scope but security is disabled. Task will run without user scope.

@ymao1 ymao1 added backport:version Backport to applied version labels 8.19 candidate v8.19.0 and removed backport:skip This PR does not require backporting 8.19 candidate labels Jun 24, 2025
@ymao1
Copy link
Contributor

ymao1 commented Jun 24, 2025

Updated the labels to backport this to 8.19

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

@JiaweiWu JiaweiWu merged commit bf0003f into elastic:main Jun 25, 2025
10 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

https://github.com/elastic/kibana/actions/runs/15864879753

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 221732

Questions ?

Please refer to the Backport tool documentation

akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request Jun 25, 2025
…ed (elastic#221732)

## Summary

Resolves: elastic#216810

This PR uses the licensing plugin to check is security is enabled. If
not, we skip adding API keys to tasks that pass in a `request` object,
but still scheduling them.

### 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
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

JiaweiWu added a commit to JiaweiWu/kibana that referenced this pull request Jun 26, 2025
…ed (elastic#221732)

## Summary

Resolves: elastic#216810

This PR uses the licensing plugin to check is security is enabled. If
not, we skip adding API keys to tasks that pass in a `request` object,
but still scheduling them.

### 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

(cherry picked from commit bf0003f)

# Conflicts:
#	x-pack/platform/plugins/shared/task_manager/server/plugin.test.ts
#	x-pack/platform/plugins/shared/task_manager/server/plugin.ts
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jun 27, 2025
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.
cc: @JiaweiWu

4 similar comments
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.
cc: @JiaweiWu

@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.
cc: @JiaweiWu

@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.
cc: @JiaweiWu

@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.
cc: @JiaweiWu

JiaweiWu added a commit that referenced this pull request Jul 3, 2025
… Disabled (#221732) (#225402)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Response Ops][Task Manager] Skip API Key Tasks If Security is
Disabled (#221732)](#221732)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Jiawei
Wu","email":"74562234+JiaweiWu@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-06-25T01:06:19Z","message":"[Response
Ops][Task Manager] Skip API Key Tasks If Security is Disabled
(#221732)\n\n## Summary\n\nResolves:
https://github.com/elastic/kibana/issues/216810\n\nThis PR uses the
licensing plugin to check is security is enabled. If\nnot, we skip
adding API keys to tasks that pass in a `request` object,\nbut still
scheduling them.\n\n### Checklist\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"bf0003f3be6711935ead682f79edec550588f5c1","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","backport:version","v9.1.0","v8.19.0"],"title":"[Response
Ops][Task Manager] Skip API Key Tasks If Security is Disabled
","number":221732,"url":"https://github.com/elastic/kibana/pull/221732","mergeCommit":{"message":"[Response
Ops][Task Manager] Skip API Key Tasks If Security is Disabled
(#221732)\n\n## Summary\n\nResolves:
https://github.com/elastic/kibana/issues/216810\n\nThis PR uses the
licensing plugin to check is security is enabled. If\nnot, we skip
adding API keys to tasks that pass in a `request` object,\nbut still
scheduling them.\n\n### Checklist\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"bf0003f3be6711935ead682f79edec550588f5c1"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/221732","number":221732,"mergeCommit":{"message":"[Response
Ops][Task Manager] Skip API Key Tasks If Security is Disabled
(#221732)\n\n## Summary\n\nResolves:
https://github.com/elastic/kibana/issues/216810\n\nThis PR uses the
licensing plugin to check is security is enabled. If\nnot, we skip
adding API keys to tasks that pass in a `request` object,\nbut still
scheduling them.\n\n### Checklist\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"bf0003f3be6711935ead682f79edec550588f5c1"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure task manager API keys are skipped and tasks still run when security is disabled in Elasticsearch

5 participants