Skip to content

[Fleet] Fix error when deleting orphaned integration policies#237875

Merged
criamico merged 4 commits intoelastic:mainfrom
criamico:237700_delete_orphaned_policies
Oct 8, 2025
Merged

[Fleet] Fix error when deleting orphaned integration policies#237875
criamico merged 4 commits intoelastic:mainfrom
criamico:237700_delete_orphaned_policies

Conversation

@criamico
Copy link
Contributor

@criamico criamico commented Oct 7, 2025

Fixes #237700

Summary

Attempting to delete an orphaned integration policy fails with a misleading error. This PR fixes this case and allows the user to force delete orphaned integration policies from Fleet APIs

Repro steps

  • Have an agent policy with an installed integration policy. For instance system
  • Get the ids of both the agent policy and the integration policy. Manually delete the agent policy (it may require a superuser user):
 DELETE .kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>
  • At this point the integration policy should be "orphaned". Try to force delete it with fleet APIs:
DELETE kbn:/api/fleet/package_policies/<integration-policy-id>?force=true

The deletion should succeed - previously it was failing with an error.

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.
@criamico criamico self-assigned this Oct 8, 2025
@criamico criamico added Team:Fleet Team label for Observability Data Collection Fleet team release_note:fix v9.3.0 v9.2.0 v9.1.0 v8.19.6 labels Oct 8, 2025
@criamico criamico marked this pull request as ready for review October 8, 2025 10:39
@criamico criamico requested a review from a team as a code owner October 8, 2025 10:39
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico
Copy link
Contributor Author

criamico commented Oct 8, 2025

@elasticmachine merge upstream

@criamico criamico added the backport:version Backport to applied version labels label Oct 8, 2025
Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

cc @criamico

@criamico criamico merged commit 14fdb32 into elastic:main Oct 8, 2025
14 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1, 9.2

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 8, 2025
…c#237875)

Fixes elastic#237700

## Summary
Attempting to delete an orphaned integration policy fails with a
misleading error. This PR fixes this case and allows the user to force
delete orphaned integration policies from Fleet APIs

### Repro steps
- Have an agent policy with an installed integration policy. For
instance `system`
- Get the ids of both the agent policy and the integration policy.
Manually delete the agent policy (it may require a `superuser` user):
```
 DELETE .kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>
```
- At this point the integration policy should be "orphaned". Try to
force delete it with fleet APIs:
```
DELETE kbn:/api/fleet/package_policies/<integration-policy-id>?force=true
```
The deletion should succeed - previously it was failing with an error.

### Checklist

- [ ] [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
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 14fdb32)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 8, 2025
…c#237875)

Fixes elastic#237700

## Summary
Attempting to delete an orphaned integration policy fails with a
misleading error. This PR fixes this case and allows the user to force
delete orphaned integration policies from Fleet APIs

### Repro steps
- Have an agent policy with an installed integration policy. For
instance `system`
- Get the ids of both the agent policy and the integration policy.
Manually delete the agent policy (it may require a `superuser` user):
```
 DELETE .kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>
```
- At this point the integration policy should be "orphaned". Try to
force delete it with fleet APIs:
```
DELETE kbn:/api/fleet/package_policies/<integration-policy-id>?force=true
```
The deletion should succeed - previously it was failing with an error.

### Checklist

- [ ] [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
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 14fdb32)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.19 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.19:
- [UII] Supporting input-level deployment_modes for integration policies (#226086)
9.1
9.2

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 237875

Questions ?

Please refer to the Backport tool documentation

@criamico
Copy link
Contributor Author

criamico commented Oct 8, 2025

💚 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

criamico added a commit to criamico/kibana that referenced this pull request Oct 8, 2025
…c#237875)

Fixes elastic#237700

## Summary
Attempting to delete an orphaned integration policy fails with a
misleading error. This PR fixes this case and allows the user to force
delete orphaned integration policies from Fleet APIs

### Repro steps
- Have an agent policy with an installed integration policy. For
instance `system`
- Get the ids of both the agent policy and the integration policy.
Manually delete the agent policy (it may require a `superuser` user):
```
 DELETE .kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>
```
- At this point the integration policy should be "orphaned". Try to
force delete it with fleet APIs:
```
DELETE kbn:/api/fleet/package_policies/<integration-policy-id>?force=true
```
The deletion should succeed - previously it was failing with an error.

### Checklist

- [ ] [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
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 14fdb32)

# Conflicts:
#	x-pack/platform/plugins/shared/fleet/server/services/package_policy.test.ts
kibanamachine added a commit that referenced this pull request Oct 8, 2025
…237875) (#238045)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Fleet] Fix error when deleting orphaned integration policies
(#237875)](#237875)

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

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

<!--BACKPORT [{"author":{"name":"Cristina
Amico","email":"criamico@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-10-08T13:21:22Z","message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","backport:version","v9.1.0","v9.2.0","v9.3.0","v8.19.6"],"title":"[Fleet]
Fix error when deleting orphaned integration
policies","number":237875,"url":"https://github.com/elastic/kibana/pull/237875","mergeCommit":{"message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","9.2","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/237875","number":237875,"mergeCommit":{"message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851"}},{"branch":"8.19","label":"v8.19.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@jen-huang
Copy link
Contributor

jen-huang commented Oct 8, 2025

Ty for the fix and all the backports! I think this could be backported to 8.18 too, I see we are planning another patch release there.

Also I think you need a Release notes section in description for the doc team's automation.

@criamico
Copy link
Contributor Author

criamico commented Oct 9, 2025

💚 All backports created successfully

Status Branch Result
8.18

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

Questions ?

Please refer to the Backport tool documentation

criamico added a commit to criamico/kibana that referenced this pull request Oct 9, 2025
…c#237875)

Fixes elastic#237700

## Summary
Attempting to delete an orphaned integration policy fails with a
misleading error. This PR fixes this case and allows the user to force
delete orphaned integration policies from Fleet APIs

### Repro steps
- Have an agent policy with an installed integration policy. For
instance `system`
- Get the ids of both the agent policy and the integration policy.
Manually delete the agent policy (it may require a `superuser` user):
```
 DELETE .kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>
```
- At this point the integration policy should be "orphaned". Try to
force delete it with fleet APIs:
```
DELETE kbn:/api/fleet/package_policies/<integration-policy-id>?force=true
```
The deletion should succeed - previously it was failing with an error.

### Checklist

- [ ] [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
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 14fdb32)

# Conflicts:
#	x-pack/platform/plugins/shared/fleet/server/services/package_policy.test.ts
#	x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts
kibanamachine added a commit that referenced this pull request Oct 9, 2025
…237875) (#238046)

# Backport

This will backport the following commits from `main` to `9.2`:
- [[Fleet] Fix error when deleting orphaned integration policies
(#237875)](#237875)

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

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

<!--BACKPORT [{"author":{"name":"Cristina
Amico","email":"criamico@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-10-08T13:21:22Z","message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","backport:version","v9.1.0","v9.2.0","v9.3.0","v8.19.6"],"title":"[Fleet]
Fix error when deleting orphaned integration
policies","number":237875,"url":"https://github.com/elastic/kibana/pull/237875","mergeCommit":{"message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","9.2","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/237875","number":237875,"mergeCommit":{"message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851"}},{"branch":"8.19","label":"v8.19.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
criamico added a commit that referenced this pull request Oct 9, 2025
…237875) (#238077)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Fleet] Fix error when deleting orphaned integration policies
(#237875)](#237875)

<!--- Backport version: 10.0.2 -->

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

<!--BACKPORT [{"author":{"name":"Cristina
Amico","email":"criamico@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-10-08T13:21:22Z","message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","backport:version","v9.1.0","v9.2.0","v9.3.0","v8.19.6"],"title":"[Fleet]
Fix error when deleting orphaned integration
policies","number":237875,"url":"https://github.com/elastic/kibana/pull/237875","mergeCommit":{"message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/238045","number":238045,"state":"OPEN"},{"branch":"9.2","label":"v9.2.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/238046","number":238046,"state":"OPEN"},{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/237875","number":237875,"mergeCommit":{"message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851"}},{"branch":"8.19","label":"v8.19.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Oct 9, 2025
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @criamico

1 similar comment
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @criamico

criamico added a commit that referenced this pull request Oct 13, 2025
…237875) (#238192)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Fleet] Fix error when deleting orphaned integration policies
(#237875)](#237875)

<!--- Backport version: 10.0.2 -->

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

<!--BACKPORT [{"author":{"name":"Cristina
Amico","email":"criamico@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-10-08T13:21:22Z","message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","backport:version","v9.2.0","v9.3.0","v9.1.6","v8.19.6"],"title":"[Fleet]
Fix error when deleting orphaned integration
policies","number":237875,"url":"https://github.com/elastic/kibana/pull/237875","mergeCommit":{"message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"9.2","label":"v9.2.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/238046","number":238046,"state":"OPEN"},{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/237875","number":237875,"mergeCommit":{"message":"[Fleet]
Fix error when deleting orphaned integration policies (#237875)\n\nFixes
https://github.com/elastic/kibana/issues/237700\n\n##
Summary\nAttempting to delete an orphaned integration policy fails with
a\nmisleading error. This PR fixes this case and allows the user to
force\ndelete orphaned integration policies from Fleet APIs\n\n\n###
Repro steps\n- Have an agent policy with an installed integration
policy. For\ninstance `system`\n- Get the ids of both the agent policy
and the integration policy.\nManually delete the agent policy (it may
require a `superuser` user):\n```\n DELETE
.kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>\n```\n- At
this point the integration policy should be \"orphaned\". Try to\nforce
delete it with fleet APIs:\n```\nDELETE
kbn:/api/fleet/package_policies/<integration-policy-id>?force=true\n```\nThe
deletion should succeed - previously it was failing with an
error.\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\n- [ ] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[ ] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"14fdb329e952918bf7f6d2ead15fbcc235932851"}},{"branch":"9.1","label":"v9.1.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/238045","number":238045,"state":"MERGED","mergeCommit":{"sha":"90b6e320e21072a606649be2f0faf792489f1768","message":"[9.1]
[Fleet] Fix error when deleting orphaned integration policies (#237875)
(#238045)\n\n# Backport\n\nThis will backport the following commits from
`main` to `9.1`:\n- [[Fleet] Fix error when deleting orphaned
integration
policies\n(#237875)](https://github.com/elastic/kibana/pull/237875)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Cristina Amico <criamico@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>"}},{"branch":"8.19","label":"v8.19.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/238077","number":238077,"state":"OPEN"}]}]
BACKPORT-->

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine kibanamachine added v8.18.9 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Oct 13, 2025
rylnd pushed a commit to rylnd/kibana that referenced this pull request Oct 17, 2025
…c#237875)

Fixes elastic#237700

## Summary
Attempting to delete an orphaned integration policy fails with a
misleading error. This PR fixes this case and allows the user to force
delete orphaned integration policies from Fleet APIs


### Repro steps
- Have an agent policy with an installed integration policy. For
instance `system`
- Get the ids of both the agent policy and the integration policy.
Manually delete the agent policy (it may require a `superuser` user):
```
 DELETE .kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>
```
- At this point the integration policy should be "orphaned". Try to
force delete it with fleet APIs:
```
DELETE kbn:/api/fleet/package_policies/<integration-policy-id>?force=true
```
The deletion should succeed - previously it was failing with an error.

### Checklist

- [ ] [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
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
NicholasPeretti pushed a commit to NicholasPeretti/kibana that referenced this pull request Oct 27, 2025
…c#237875)

Fixes elastic#237700

## Summary
Attempting to delete an orphaned integration policy fails with a
misleading error. This PR fixes this case and allows the user to force
delete orphaned integration policies from Fleet APIs


### Repro steps
- Have an agent policy with an installed integration policy. For
instance `system`
- Get the ids of both the agent policy and the integration policy.
Manually delete the agent policy (it may require a `superuser` user):
```
 DELETE .kibana_ingest/_doc/fleet-agent-policies:<agent-policy-id>
```
- At this point the integration policy should be "orphaned". Try to
force delete it with fleet APIs:
```
DELETE kbn:/api/fleet/package_policies/<integration-policy-id>?force=true
```
The deletion should succeed - previously it was failing with an error.

### Checklist

- [ ] [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
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
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:fix Team:Fleet Team label for Observability Data Collection Fleet team v8.18.9 v8.19.6 v9.1.6 v9.2.0 v9.3.0

5 participants