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] Don't fail on errors in 'update' or 'reupdate' operation in /setup #97402

Closed
wants to merge 15 commits into from

Conversation

skh
Copy link
Contributor

@skh skh commented Apr 18, 2021

Summary

Completes first implementation of #91864
Follow-up to #95649

This changes /api/fleet/setup such that

  • it doesn't error when an error happens during a package upgrade
  • its response now contains a property nonFatalPackageUpgradeErrors that reports all errors that have happened during package upgrade

This also changes the Fleet UI so that it shows an error toast when nonFatalPackageUpgradeErrors exists and is not empty.

How to test this:

Craft a system package that triggers an error during installation, serve it from a locally running registry. Do do so, edit any dashboard in system/0.10.9 to include

"migrationVersion": {
    "dashboard": "9.3.0"
  }

instead of 7.3.0.

Start Kibana. Do NOT open the UI yet.

Install a previous, non-broken version of the package with

curl -X POST -u elastic:changeme http://localhost:5601/rch/api/fleet/epm/packages/system-0.10.7 -H 'kbn-xsrf: xyz' -H "Content-Type: application/json" -d '{"force": true}'

Call the setup API endpoint with

curl -X POST -u elastic:changeme http://localhost:5601/rch/api/fleet/setup -H 'kbn-xsrf: xyz'

Observe that the return value contains the error, but also isInitialized: true.


Now navigate to the Fleet UI. Observe that you see the full Fleet UI, with an error toast like this:
image

In dev tools / network, verify that you see the error contained in the response:
image


Now uninstall the nonbroken package (or restart your dev setup to start with an empty database) and call /api/fleet/setup immediately. Verify that it still returns an error (because the error happens during installation, not upgrade).

Open the Fleet UI and verify that you can't use it because the error during installation.


Test against the official registry to verify that setup with good packages still works as expected.

Known issues

When you click on "Show the full error" in the error toast, the next modal is empty. I couldn't find a way to pass the error array to the toast notification in the correct form, any help would be appreciated. The full error is visible in dev tools, so I'd suggest this can be fixed in a follow-up change unless I missed something trivial.

When testing that installation of a broken package still blocks the whole UI, #97401 happens.

@skh skh added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Fleet Fleet team's agent central management project Team:Fleet Team label for Observability Data Collection Fleet team v7.13.0 labels Apr 18, 2021
@skh skh self-assigned this Apr 18, 2021
@skh skh requested a review from a team as a code owner April 18, 2021 14:56
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Feature:Fleet)

@skh
Copy link
Contributor Author

skh commented Apr 18, 2021

Closing in favor of #97404 because mess-up, sorry for the noise.

@skh skh closed this Apr 18, 2021
@kibanamachine
Copy link
Contributor

kibanamachine commented Apr 18, 2021

💔 Build Failed

Failed CI Steps


Test Failures

Kibana Pipeline / jest / Jest Tests.x-pack/plugins/fleet/server/services/epm/packages.ensureInstalledDefaultPackages should return an array of Installation objects when successful

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expect(received).toEqual(expected) // deep equality

Expected: [{"es_index_patterns": {"pattern": "pattern-name"}, "id": "test-pkg", "install_source": "registry", "install_started_at": "2021-04-18T16:07:48.260Z", "install_status": "installed", "install_version": "1.0.0", "installed_es": [{"id": "pipeline", "type": "ingest_pipeline"}], "installed_kibana": [{"id": "dashboard-1", "type": "dashboard"}], "name": "test package", "package_assets": [], "version": "1.0.0"}]
Received: {"installations": [{"es_index_patterns": {"pattern": "pattern-name"}, "id": "test-pkg", "install_source": "registry", "install_started_at": "2021-04-18T16:07:48.260Z", "install_status": "installed", "install_version": "1.0.0", "installed_es": [{"id": "pipeline", "type": "ingest_pipeline"}], "installed_kibana": [{"id": "dashboard-1", "type": "dashboard"}], "name": "test package", "package_assets": [], "version": "1.0.0"}], "nonFatalPackageUpgradeErrors": []}
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/fleet/server/services/epm/packages/ensure_installed_default_packages.test.ts:87:18)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at _callCircusTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:212:5)
    at _runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:149:3)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:63:9)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:57:9)
    at run (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:176:21)
    at jestAdapter (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:109:19)
    at runTestInternal (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:380:16)
    at runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:472:34)
    at Object.worker (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/testWorker.js:133:12)

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 787.8KB 788.1KB +306.0B
Unknown metric groups

API count

id before after diff
fleet 1069 1075 +6

API count missing comments

id before after diff
fleet 979 985 +6

History

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

cc @skh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Fleet Fleet team's agent central management project release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants