[9.0] [Fleet] skip output validation when create/update package policy (#216438) (#216497)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Fleet] skip output validation when create/update package policy
(#216438)](https://github.com/elastic/kibana/pull/216438)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Julia
Bardi","email":"90178898+juliaElastic@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-31T15:07:23Z","message":"[Fleet]
skip output validation when create/update package policy (#216438)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198107\n\nSkip output
validation on bump agent policy, it's unnecessary after the\npackage
policy create/update logic already does the validation with the\ncorrect
integration output.\n\nTo verify:\n- Create an agent policy with a
remote ES output as data output\n- Add fleet server integration - expect
error as the default remote ES\noutput can't be used with fleet
server\n- Change integration output to the ES output - expect
creation\nsuccessful\n- Edit fleet server integration (keep ES output) -
expect update\nsuccessful\n\n<img width=\"1685\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/42a0365c-1f00-42b6-b685-7797e9c916de\"\n/>\n<img
width=\"1714\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/af22cea1-d8b3-4d44-a24d-78dff49eeaaa\"\n/>\n<img
width=\"1699\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/aafc7e5c-b9e6-47b8-9001-16e08cf06205\"\n/>\n<img
width=\"1704\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/e6e7ef47-918a-423f-a54c-11836362d495\"\n/>\n<img
width=\"1712\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/128ef119-2178-4971-9e0f-bb773c2f774a\"\n/>\n<img
width=\"1707\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cd49716d-aa38-42ff-9329-3d97f08f9e7e\"\n/>\n\n\n###
Checklist\n\n- [ ] [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":"7adc1821d83fa9ed913de1b6624adfc1b7640003","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-minor","v9.1.0"],"title":"[Fleet]
skip output validation when create/update package
policy","number":216438,"url":"https://github.com/elastic/kibana/pull/216438","mergeCommit":{"message":"[Fleet]
skip output validation when create/update package policy (#216438)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198107\n\nSkip output
validation on bump agent policy, it's unnecessary after the\npackage
policy create/update logic already does the validation with the\ncorrect
integration output.\n\nTo verify:\n- Create an agent policy with a
remote ES output as data output\n- Add fleet server integration - expect
error as the default remote ES\noutput can't be used with fleet
server\n- Change integration output to the ES output - expect
creation\nsuccessful\n- Edit fleet server integration (keep ES output) -
expect update\nsuccessful\n\n<img width=\"1685\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/42a0365c-1f00-42b6-b685-7797e9c916de\"\n/>\n<img
width=\"1714\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/af22cea1-d8b3-4d44-a24d-78dff49eeaaa\"\n/>\n<img
width=\"1699\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/aafc7e5c-b9e6-47b8-9001-16e08cf06205\"\n/>\n<img
width=\"1704\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/e6e7ef47-918a-423f-a54c-11836362d495\"\n/>\n<img
width=\"1712\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/128ef119-2178-4971-9e0f-bb773c2f774a\"\n/>\n<img
width=\"1707\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cd49716d-aa38-42ff-9329-3d97f08f9e7e\"\n/>\n\n\n###
Checklist\n\n- [ ] [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":"7adc1821d83fa9ed913de1b6624adfc1b7640003"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216438","number":216438,"mergeCommit":{"message":"[Fleet]
skip output validation when create/update package policy (#216438)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198107\n\nSkip output
validation on bump agent policy, it's unnecessary after the\npackage
policy create/update logic already does the validation with the\ncorrect
integration output.\n\nTo verify:\n- Create an agent policy with a
remote ES output as data output\n- Add fleet server integration - expect
error as the default remote ES\noutput can't be used with fleet
server\n- Change integration output to the ES output - expect
creation\nsuccessful\n- Edit fleet server integration (keep ES output) -
expect update\nsuccessful\n\n<img width=\"1685\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/42a0365c-1f00-42b6-b685-7797e9c916de\"\n/>\n<img
width=\"1714\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/af22cea1-d8b3-4d44-a24d-78dff49eeaaa\"\n/>\n<img
width=\"1699\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/aafc7e5c-b9e6-47b8-9001-16e08cf06205\"\n/>\n<img
width=\"1704\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/e6e7ef47-918a-423f-a54c-11836362d495\"\n/>\n<img
width=\"1712\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/128ef119-2178-4971-9e0f-bb773c2f774a\"\n/>\n<img
width=\"1707\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cd49716d-aa38-42ff-9329-3d97f08f9e7e\"\n/>\n\n\n###
Checklist\n\n- [ ] [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":"7adc1821d83fa9ed913de1b6624adfc1b7640003"}}]}]
BACKPORT-->

Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2025-03-31 18:57:34 +02:00 committed by GitHub
parent 9e9f9ac37c
commit 41bf1ef7b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -906,13 +906,18 @@ class AgentPolicyService {
soClient: SavedObjectsClientContract,
esClient: ElasticsearchClient,
id: string,
options?: { user?: AuthenticatedUser; removeProtection?: boolean; asyncDeploy?: boolean }
options?: {
user?: AuthenticatedUser;
removeProtection?: boolean;
asyncDeploy?: boolean;
skipValidation?: boolean;
}
): Promise<void> {
return withSpan('bump_agent_policy_revision', async () => {
await this._update(soClient, esClient, id, {}, options?.user, {
bumpRevision: true,
removeProtection: options?.removeProtection ?? false,
skipValidation: false,
skipValidation: options?.skipValidation ?? true,
returnUpdatedPolicy: false,
asyncDeploy: options?.asyncDeploy,
});