Skip to content

[Fleet] Split package policy Upgrade endpoint - #118854

Merged
criamico merged 2 commits into
elastic:mainfrom
criamico:115570_split_upgrade_endpoint
Nov 19, 2021
Merged

criamico merged 2 commits into
elastic:mainfrom
criamico:115570_split_upgrade_endpoint

Conversation

@criamico

@criamico criamico commented Nov 17, 2021 •

Copy link
Copy Markdown
Member

Summary

Closes #115570

Breaking change in the package policies upgrade API

The packagePolicy upgrade endpoint currently has this format. It supports a mutative upgrade operation (when dryRun: false) and a read-only dry run operation (when dryRun: true) for package policy upgrades:

POST /package_policies/upgrade
{
  packagePolicyIds: [...],
  dryRun: false
}

As part of a general reordering of Fleet APIs, this endpoint will now be split in two separate endpoints:

POST /package_policies/upgrade
{
  packagePolicyIds: [...]
}

POST /package_policies/upgrade/dry_run
{
  packagePolicyIds: [...]
}

Repro steps

  • Navigate to app/fleet/integrations/docker-1.0.0/add-integration to install an older version of docker
  • Go to the network tab and get the packagePolicyId of this integration

Test case 1: Dry run

  • Using postman or curl, post to /package_policies/upgrade/dryrun. An example of body targeting docker version 1.1.1 is
{
  "packagePolicyIds": ["23020b5e-39fa-4421-8c77-05b184b96fd0"],
  "packageVersion": "1.1.1"
}
- The upgrade should work properly

Test case 2: Upgrade

  • Using postman or curl, post to /package_policies/upgrade. An example of body:
{
  "packagePolicyIds": ["23020b5e-39fa-4421-8c77-05b184b96fd0"],
}
  • The dry run should work normally

Test case 3: Upgrade (in UI):

  • Same as before, install an older version of a package
  • Go to Integrations settings, click on the "Upgrade to latest version", it will trigger the modal
  • Click on "upgrade". In the network tab both the dryrun and the upgrade endpoint should work successfully

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@criamico
criamico force-pushed the 115570_split_upgrade_endpoint branch from 768aa75 to 8b649d6 Compare November 17, 2021 14:24
@criamico criamico self-assigned this Nov 17, 2021
@criamico criamico added auto-backport Deprecated - use backport:version if exact versions are needed v8.0.0 v8.1.0 release_note:breaking Team:Fleet - DEPRECATED Use Team:streams-ui labels Nov 17, 2021
@criamico
criamico force-pushed the 115570_split_upgrade_endpoint branch from 8b649d6 to 1003c6c Compare November 17, 2021 14:56
@criamico criamico changed the title [Fleet] Split upgrade endpoint [Fleet] Split package policy Upgrade endpoint Nov 17, 2021
@criamico
criamico marked this pull request as ready for review November 17, 2021 15:08
@criamico
criamico requested a review from a team as a code owner November 17, 2021 15:08
@elasticmachine

Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico
criamico requested a review from kpollich November 17, 2021 15:08
@criamico
criamico force-pushed the 115570_split_upgrade_endpoint branch from 1003c6c to 4af2a2a Compare November 17, 2021 16:23
@nchaulet

Copy link
Copy Markdown
Member

Should we update some OpenAPI spec file for these endpoints too?

@juliaElastic

Copy link
Copy Markdown
Contributor

Tested locally and looks good, though sometimes I'm seeing http 400 errors on dryrun (I think this was already there before your changes).
I'm wondering why we throw an error if the package policy is up to date.
[2021-11-18T10:14:01.875+01:00][ERROR][plugins.fleet] Package policy 79f711f0-bf8b-4ab1-86ad-da697fee59d7's package version 1.1.1 of package docker is up to date with the installed package. Please install the latest version of docker.
image

@criamico

Copy link
Copy Markdown
Member Author

@juliaElastic I'm not sure why we throw that error, I'll try to take a look.

@nchaulet I'll add the openApi specs in this PR, actually I was thinking to add them later, as we have a task to revise all of them, them but it's probably nicer to keep them in sync

@criamico
criamico force-pushed the 115570_split_upgrade_endpoint branch from 7027e4f to 714770d Compare November 18, 2021 10:46

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

summary should mention dry run

@criamico
criamico force-pushed the 115570_split_upgrade_endpoint branch from 714770d to 3a1ab4c Compare November 18, 2021 13:23
@criamico
criamico force-pushed the 115570_split_upgrade_endpoint branch from 3a1ab4c to e9f3a7a Compare November 18, 2021 13:25
@kibana-ci

Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fleet 1125 1127 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 104.7KB 104.7KB +54.0B
Unknown metric groups

API count

id before after diff
fleet 1227 1229 +2

History

  • 💚 Build #7617 succeeded 714770d15807271e177edd8e4956d9bd29f16828
  • 💚 Build #7420 succeeded 4af2a2ac52596ee28a401b0bb19c2a534094d6d8
  • 💔 Build #7392 failed 8b649d6ecaf2d03e4bb5a7434652f15d181688de
  • 💔 Build #7330 failed 768aa7536efe3183c85d6780c2e6efe66086b863

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

cc @criamico

@nchaulet nchaulet left a comment

Copy link
Copy Markdown
Member

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 ad6b687 into elastic:main Nov 19, 2021
@criamico
criamico deleted the 115570_split_upgrade_endpoint branch November 19, 2021 10:29
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 19, 2021
* [Fleet] Split package policy Upgrade endpoint

* Add openapi specs
@kibanamachine

Copy link
Copy Markdown
Contributor

💚 Backport successful

Status Branch Result
✅ 8.0

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Nov 19, 2021
* [Fleet] Split package policy Upgrade endpoint

* Add openapi specs

Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
TinLe pushed a commit to TinLe/kibana that referenced this pull request Nov 20, 2021
* [Fleet] Split package policy Upgrade endpoint

* Add openapi specs
dmlemeshko pushed a commit that referenced this pull request Nov 29, 2021
* [Fleet] Split package policy Upgrade endpoint

* Add openapi specs
patrykkopycinski pushed a commit to patrykkopycinski/kibana that referenced this pull request May 6, 2026
* [Fleet] Split package policy Upgrade endpoint

* Add openapi specs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Deprecated - use backport:version if exact versions are needed release_note:breaking Team:Fleet - DEPRECATED Use Team:streams-ui v8.0.0 v8.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fleet] Rework "Dry Run" package policy upgrade logic into its own endpoint

6 participants