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] added fleet setup before installing integration #121379

Merged
merged 3 commits into from
Dec 17, 2021

Conversation

juliaElastic
Copy link
Contributor

@juliaElastic juliaElastic commented Dec 16, 2021

Summary

Fix #120358

Calling setup fleet first when clicking on integration install button.

  • if fleet setup hasn't been done yet, the setup takes some time, so showing disabled "Installing" button.
  • If fleet setup has been done already, the call returns quickly

Steps to verify:

  1. Start Kibana and ES 7.16.0 without Fleet Server, do not go to Fleet app
  2. Go directly to an Integration detail settings tab, such as http://localhost:5601/app/integrations/detail/nginx-1.2.3/settings
  3. Click install button
  4. Verify on Network tab that fleet setup is called, and during that time, cannot click Install button again.
  5. After setup returns, install should be completing successfully

Repeat the above with another integration and verify that setup is called and returning quickly.

image

image

What is alarming though is that first time the setup call takes almost 2 mins, and I see a few errors in kibana logs as well:

server    log   [10:04:43.409] [warning][fleet][plugins] Failure to install package [elastic_agent]: [{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"component template [metrics-elastic_agent.osquerybeat@custom] already exists"}],"type":"illegal_argument_exception","reason":"component template [metrics-elastic_agent.osquerybeat@custom] already exists"},"status":400}]
server    log   [10:04:43.410] [error][fleet][plugins] uninstalling elastic_agent-1.3.0 after error installing: [{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"component template [metrics-elastic_agent.osquerybeat@custom] already exists"}],"type":"illegal_argument_exception","reason":"component template [metrics-elastic_agent.osquerybeat@custom] already exists"},"status":400}]
server    log   [10:04:43.413] [error][fleet][plugins] failed to uninstall or rollback package after installation error Error: elastic_agent is installed by default and cannot be removed
server    log   [10:05:24.737] [warning][fleet][plugins] Failed installing package [elastic_agent] due to error: [{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"component template [metrics-elastic_agent.osquerybeat@custom] already exists"}],"type":"illegal_argument_exception","reason":"component template [metrics-elastic_agent.osquerybeat@custom] already exists"},"status":400}]

The same errors come when I navigate to Fleet to trigger setup first (on 7.16 branch)

@juliaElastic juliaElastic self-assigned this Dec 16, 2021
@juliaElastic juliaElastic added release_note:skip Skip the PR/issue when compiling release notes v7.17.0 Team:Fleet Team label for Observability Data Collection Fleet team labels Dec 16, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@juliaElastic juliaElastic requested a review from a team December 16, 2021 10:37
@nchaulet
Copy link
Member

@juliaElastic The error you get seems to happens some time locally I think due to a race condition. That PR fix it in 8.0 but we should probably backport it to 7.16.x too #120819

toggleInstallModal();
await sendPostFleetSetup({ forceRecreate: false });
Copy link
Member

Choose a reason for hiding this comment

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

We may want to handle the error happening in sendPostFleetSetup we probably want to close the install modal and show the error in a toast notification as we do in other place what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point! do you think the installPackage should continue if setup fails? to fall back to the existing logic

Copy link
Member

Choose a reason for hiding this comment

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

Sure we can just catch the error add a toast and try to install the package 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added error toast, though it shows up for a short time only by default

simulated error by throwing error on backend:
image

image

const handleClickInstall = useCallback(async () => {
setFleetSetupInProgress(true);
toggleInstallModal();
await sendPostFleetSetup({ forceRecreate: false });
const res = await sendPostFleetSetup({ forceRecreate: false });
Copy link
Member

Choose a reason for hiding this comment

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

a little nitpick but I would put this in a try catch to avoid uncaught exception here.

try {
const res = await sendPostFleetSetup({ forceRecreate: false });
if (res.error) {
 throw res.error;
}
} catch (e) {
 // show toast
}

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

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 626.2KB 626.8KB +635.0B

Page load bundle

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

id before after diff
fleet 108.2KB 108.5KB +277.0B

History

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

cc @juliaElastic

@juliaElastic juliaElastic changed the base branch from 7.16 to 7.17 December 17, 2021 06:56
@juliaElastic
Copy link
Contributor Author

FYI moved the target branch to 7.17

@juliaElastic juliaElastic merged commit 887a955 into elastic:7.17 Dec 17, 2021
@juliaElastic juliaElastic deleted the fix-integrations-install branch December 17, 2021 07:13
@joshdover
Copy link
Contributor

@juliaElastic in case we have another 7.16.x release, can we backport this there as well?

@amolnater-qasource
Copy link

Hi @joshdover & @juliaElastic
We have revalidated this on released 7.16.2 self-managed environment and we are successfully able to reproduce this issue.

  • Unable to install Nginx integration on fresh kibana setup, when user didn't navigate to fleet tab.

Build details:
Build: 46307
Commit: 9b678a1
Artifact Link: https://www.elastic.co/downloads/past-releases/elasticsearch-7-16-2

Screenshot:
1

Further, we have also validated the same on latest 8.0 self-managed environment and we have found it fixed there.

  • Successfully able to install Nginx integration on fresh kibana setup, when user didn't navigate to fleet tab.

Build details:
Build: 48805
Commit: 002f9fa
Artifact Link: https://snapshots.elastic.co/8.0.0-7b79b556/downloads/kibana/kibana-8.0.0-SNAPSHOT-windows-x86_64.zip

Screenshot:
3

Thanks

@juliaElastic
Copy link
Contributor Author

@joshdover sorry I missed you comment earlier. I'll backport to 7.16 branch

@juliaElastic
Copy link
Contributor Author

💔 Some backports could not be created

Status Branch Result
7.16 Command failed: git reset --hard && git clean -d --force && git fetch elastic 7.16 && git checkout -B backport/7.16/pr-121379 elastic/7.16 --no-track
fatal: not a git repository (or any of the parent directories): .git

|

To backport manually run: node scripts/backport --pr 121379.
For more info read the Backport documentation

1 similar comment
@juliaElastic
Copy link
Contributor Author

💔 Some backports could not be created

Status Branch Result
7.16 Command failed: git reset --hard && git clean -d --force && git fetch elastic 7.16 && git checkout -B backport/7.16/pr-121379 elastic/7.16 --no-track
fatal: not a git repository (or any of the parent directories): .git

|

To backport manually run: node scripts/backport --pr 121379.
For more info read the Backport documentation

juliaElastic added a commit to juliaElastic/kibana that referenced this pull request Jan 10, 2022
* added fleet setup before installing integration

* added fleet setup error toast message

* added try catch
juliaElastic added a commit that referenced this pull request Jan 10, 2022
…22509)

* added fleet setup before installing integration

* added fleet setup error toast message

* added try catch
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.17.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants