Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] update getPackageInfo to handle uploaded packages #83854

Merged

Conversation

neptunian
Copy link
Contributor

@neptunian neptunian commented Nov 19, 2020

getPackageInfo is the handler for the route /api/fleet/epm/packages/{pkg}. Before this change it always reached out to the registry to get the package. For example if you uploaded a package called apache-0.1.4 and visited /api/fleet/epm/packages/apache-0.1.4 the registry package would be returned and not the one you uploaded. This updates to check the install source, if installed, and fetch from that source.

  • update getPackageInfo to look at install source before looking for the package. If an uploaded package doesn't exist in memory, it will throw an error. This will be updated once the package storage is available and it would look there next before throwing an error, probably a 404.

  • update the .zip and .tar.gz fixtures for apache-0.1.4 package to differentiate itself from the one in the registry to make testing easier. the description in the manifest was changed and the README.md in /docs to say "Apache Uploaded Test Integration". This is compared in an integration test and you can easily see the different when navigating to the package details in the UI

  • introduces getPackageFromSource which can be updated once the package storage is available.

This change is needed for #83312 and #83311

Test:

  1. Upload a package
    curl -X POST -u elastic:changeme http://localhost:5603/ssg/api/fleet/epm/packages --data-binary @dev/elastic/kibana/x-pack/test/fleet_api_integration/apis/fixtures/direct_upload_packages/apache_0.1.4.tar.gz -H 'kbn-xsrf: xyz' -H 'Content-Type: application/gzip'
  2. Visit the route and see that the uploaded package information is being returned

Screen Shot 2020-11-19 at 2 56 34 PM

  1. Uninstall apache-0.1.4
  2. Visit the route again and see the registry version is returned

Screen Shot 2020-11-19 at 2 55 55 PM

@neptunian neptunian added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.11.0 labels Nov 19, 2020
@neptunian neptunian requested a review from a team November 19, 2020 19:58
@neptunian neptunian self-assigned this Nov 19, 2020
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Nov 19, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

Copy link
Contributor

@jfsiii jfsiii left a comment

Choose a reason for hiding this comment

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

Yay! Thanks for adding the tests. Didn't get to run locally, but LGTM. Left some comments but nothing that can't be addressed later.

x-pack/plugins/fleet/server/services/epm/packages/get.ts Outdated Show resolved Hide resolved
x-pack/test/fleet_api_integration/apis/epm/get.ts Outdated Show resolved Hide resolved
export type PackageInfo =
| Installable<
// remove the properties we'll be altering/replacing from the base type
Omit<RegistryPackage, keyof PackageAdditions> &
Copy link
Contributor

Choose a reason for hiding this comment

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

Not able to check right now, but does this not work as Omit<RegistryPackage|ArchivePackage?

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 not exactly sure why, but it breaks a type like this:
Screen Shot 2020-11-20 at 8 02 00 AM.
The error is:
Type '{ name: string; title: string; version: string; latestVersion: string; description: string; type: string; categories: never[]; requirement: { kibana: { versions: string; }; elasticsearch: { versions: string; }; }; ... 4 more ...; status: "not_installed"; }' is not assignable to type 'Installable<Pick<RegistryPackage | ArchivePackage, "name" | "version" | "release" | "description" | "type" | "icons" | "internal" | "data_streams" | ... 4 more ... | "format_version"> & PackageAdditions>'. Object literal may only specify known properties, and 'requirement' does not exist in type 'NotInstalled<Pick<RegistryPackage | ArchivePackage, "name" | "version" | "release" | "description" | "type" | "icons" | "internal" | "data_streams" | ... 4 more ... | "format_version"> & PackageAdditions>'.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@neptunian neptunian merged commit 39291e1 into elastic:master Nov 20, 2020
neptunian added a commit to neptunian/kibana that referenced this pull request Nov 20, 2020
)

* update getPackgeInfo handler to fetch from install source

* add tests and modify fixtures  to distinguish between registry and uploaded package

* improve error handling

* fix type

* fix test

* remove try/catch

* fix zip file test to have the right number of assets

* fix compressed files
neptunian added a commit to neptunian/kibana that referenced this pull request Nov 20, 2020
)

* update getPackgeInfo handler to fetch from install source

* add tests and modify fixtures  to distinguish between registry and uploaded package

* improve error handling

* fix type

* fix test

* remove try/catch

* fix zip file test to have the right number of assets

* fix compressed files
neptunian added a commit that referenced this pull request Nov 20, 2020
…83965)

* update getPackgeInfo handler to fetch from install source

* add tests and modify fixtures  to distinguish between registry and uploaded package

* improve error handling

* fix type

* fix test

* remove try/catch

* fix zip file test to have the right number of assets

* fix compressed files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants