Skip to content

[Fleet] Replace call to registry when deleting kibana assets for custom packages#224886

Merged
criamico merged 6 commits intoelastic:mainfrom
criamico:224191_delete_assets_bug
Jun 25, 2025
Merged

[Fleet] Replace call to registry when deleting kibana assets for custom packages#224886
criamico merged 6 commits intoelastic:mainfrom
criamico:224191_delete_assets_bug

Conversation

@criamico
Copy link
Contributor

@criamico criamico commented Jun 23, 2025

Fixes #224191

Summary

Bugfix - Replace call to registry when deleting kibana assets for packages of type "custom" and "bundled". Also replaced the call to fetchInfo.registry on another code path to avoid errors in the same situation -

  • These calls are replaced with getPackageInfo, that has some internal functionalities to decide when the packageInfo should be fetched from the cache, ES or the registry.
  • Added additional logging to the delete assets functions

Testing

  • Install a custom integration that has some assets (a dashboard for instance)
  • Uninstall it and check that the asset is correctly removed and there are no errors:
Screenshot 2025-06-25 at 11 02 39

Checklist

@criamico criamico added the Team:Fleet Team label for Observability Data Collection Fleet team label Jun 23, 2025
@criamico criamico self-assigned this Jun 23, 2025
@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @criamico

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

pkgName: name,
pkgVersion: version,
skipArchive: installSource !== 'registry',
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main fix: used getPackageInfo instead of calling the registry.

pkgName: installedPkg.attributes.name,
pkgVersion: installedPkg.attributes.version,
skipArchive: installedPkg.attributes.install_source !== 'registry',
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replacing it also here, it is a different code path but this way we ensure that packages that it doesn't error for packages not installed from registry.

@criamico criamico marked this pull request as ready for review June 25, 2025 09:12
@criamico criamico requested a review from a team as a code owner June 25, 2025 09:13
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

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

@criamico criamico merged commit 550b9d5 into elastic:main Jun 25, 2025
16 checks passed
@criamico criamico deleted the 224191_delete_assets_bug branch June 25, 2025 12:21
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.0

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

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
9.0 Backport failed because of merge conflicts

You might need to backport the following PRs to 9.0:
- [Fleet] When removing a inputs type package policy, clean up assets (#218582)

Manual backport

To create the backport manually run:

node scripts/backport --pr 224886

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Jun 25, 2025
@criamico criamico added backport:prev-minor and removed backport:skip This PR does not require backporting labels Jun 25, 2025
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.0

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

@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.0

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

@criamico
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.0

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

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
9.0 Backport failed because of merge conflicts

You might need to backport the following PRs to 9.0:
- [Fleet] When removing a inputs type package policy, clean up assets (#218582)

Manual backport

To create the backport manually run:

node scripts/backport --pr 224886

Questions ?

Please refer to the Backport tool documentation

1 similar comment
@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
9.0 Backport failed because of merge conflicts

You might need to backport the following PRs to 9.0:
- [Fleet] When removing a inputs type package policy, clean up assets (#218582)

Manual backport

To create the backport manually run:

node scripts/backport --pr 224886

Questions ?

Please refer to the Backport tool documentation

criamico added a commit to criamico/kibana that referenced this pull request Jun 25, 2025
…om packages (elastic#224886)

Fixes elastic#224191

## Summary

Bugfix - Replace call to registry when deleting kibana assets for
packages of type "custom" and "bundled". Also replaced the call to
`fetchInfo.registry` on another code path to avoid errors in the same
situation -
- These calls are replaced with `getPackageInfo`, that has some internal
functionalities to decide when the packageInfo should be fetched from
the cache, ES or the registry.
- Added additional logging to the delete assets functions

### Testing
- Install a custom integration that has some assets (a dashboard for
instance)
- Uninstall it and check that the asset is correctly removed and there
are no errors:

<img width="1453" alt="Screenshot 2025-06-25 at 11 02 39"
src="https://github.com/user-attachments/assets/32fb07f3-2628-4e30-be92-16610043b3ae"
/>

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

---------

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

# Conflicts:
#	x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install.ts
#	x-pack/platform/plugins/shared/fleet/server/services/epm/packages/remove.ts
criamico added a commit that referenced this pull request Jun 25, 2025
…r custom packages (#224886) (#225288)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Fleet] Replace call to registry when deleting kibana assets for
custom packages
(#224886)](#224886)

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

### 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-06-25T12:21:41Z","message":"[Fleet]
Replace call to registry when deleting kibana assets for custom packages
(#224886)\n\nFixes https://github.com/elastic/kibana/issues/224191\n\n##
Summary\n\nBugfix - Replace call to registry when deleting kibana assets
for\npackages of type \"custom\" and \"bundled\". Also replaced the call
to\n`fetchInfo.registry` on another code path to avoid errors in the
same\nsituation -\n- These calls are replaced with `getPackageInfo`,
that has some internal\nfunctionalities to decide when the packageInfo
should be fetched from\nthe cache, ES or the registry.\n- Added
additional logging to the delete assets functions\n\n### Testing\n-
Install a custom integration that has some assets (a dashboard
for\ninstance)\n- Uninstall it and check that the asset is correctly
removed and there\nare no errors:\n\n<img width=\"1453\"
alt=\"Screenshot 2025-06-25 at 11 02
39\"\nsrc=\"https://github.com/user-attachments/assets/32fb07f3-2628-4e30-be92-16610043b3ae\"\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\n\n---------\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"550b9d58eab13c9ba46615808330e0579c44ce65","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","backport:prev-minor","v9.1.0"],"title":"[Fleet]
Replace call to registry when deleting kibana assets for custom
packages","number":224886,"url":"https://github.com/elastic/kibana/pull/224886","mergeCommit":{"message":"[Fleet]
Replace call to registry when deleting kibana assets for custom packages
(#224886)\n\nFixes https://github.com/elastic/kibana/issues/224191\n\n##
Summary\n\nBugfix - Replace call to registry when deleting kibana assets
for\npackages of type \"custom\" and \"bundled\". Also replaced the call
to\n`fetchInfo.registry` on another code path to avoid errors in the
same\nsituation -\n- These calls are replaced with `getPackageInfo`,
that has some internal\nfunctionalities to decide when the packageInfo
should be fetched from\nthe cache, ES or the registry.\n- Added
additional logging to the delete assets functions\n\n### Testing\n-
Install a custom integration that has some assets (a dashboard
for\ninstance)\n- Uninstall it and check that the asset is correctly
removed and there\nare no errors:\n\n<img width=\"1453\"
alt=\"Screenshot 2025-06-25 at 11 02
39\"\nsrc=\"https://github.com/user-attachments/assets/32fb07f3-2628-4e30-be92-16610043b3ae\"\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\n\n---------\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"550b9d58eab13c9ba46615808330e0579c44ce65"}},"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/224886","number":224886,"mergeCommit":{"message":"[Fleet]
Replace call to registry when deleting kibana assets for custom packages
(#224886)\n\nFixes https://github.com/elastic/kibana/issues/224191\n\n##
Summary\n\nBugfix - Replace call to registry when deleting kibana assets
for\npackages of type \"custom\" and \"bundled\". Also replaced the call
to\n`fetchInfo.registry` on another code path to avoid errors in the
same\nsituation -\n- These calls are replaced with `getPackageInfo`,
that has some internal\nfunctionalities to decide when the packageInfo
should be fetched from\nthe cache, ES or the registry.\n- Added
additional logging to the delete assets functions\n\n### Testing\n-
Install a custom integration that has some assets (a dashboard
for\ninstance)\n- Uninstall it and check that the asset is correctly
removed and there\nare no errors:\n\n<img width=\"1453\"
alt=\"Screenshot 2025-06-25 at 11 02
39\"\nsrc=\"https://github.com/user-attachments/assets/32fb07f3-2628-4e30-be92-16610043b3ae\"\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\n\n---------\n\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"550b9d58eab13c9ba46615808330e0579c44ce65"}}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team v9.0.4 v9.1.0

4 participants