elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.64k stars 8.22k forks source link

[Fleet] Uninstall assets broken for packages installed via upload #194297

Open criamico opened 1 month ago

criamico commented 1 month ago

Kibana version: present in 8.15 and on 9.0.0 main

Description

Uninstalling package assets throws an error for packages installed via upload.

Repro steps

Install a package via upload. It can be done via elastic-package install --zip or

curl -XPOST -H 'content-type: application/zip' -H 'kbn-xsrf: true' http://localhost:5601/YOUR_PATH/api/fleet/epm/packages -u elastic:changeme --data-binary @test_package-1.0.1-rc1.zip

Now try to uninstall its assets. From the UI, go to the installed integration and click on the uninstall button under "Settings" tab.

In the logs there are following errors:

PackageNotFoundError: test_package@1.0.1-rc1 not found
    at Object.fetchInfo (index.ts:181:13)
    at deleteAssets (remove.ts:337:25)
    at removeInstallation (remove.ts:98:3)
    at deletePackageHandler (handlers.ts:531:17)

Which points to https://github.com/elastic/kibana/blob/a20d92f5bb8da88b6dd007ece468bc9bbd440c71/xpack/plugins/fleet/server/services/epm/packages/remove.ts#L3[…]347

The issue is that we're trying to reach the registry even for a local package, which shouldn't be the case.

Note that from the UI looks like the package was successfully removed, but doing a query for the assets still finds them installed. In fact the asset uninstall is done just after the Registry.fetchInfo call that throws.

elasticmachine commented 1 month ago

Pinging @elastic/fleet (Team:Fleet)