Skip to content

[Fleet] fix setup error during test #120917

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

Merged
merged 1 commit into from
Dec 10, 2021

Conversation

juliaElastic
Copy link
Contributor

@juliaElastic juliaElastic commented Dec 9, 2021

Summary

Fixing flaky tests caused by error in fleet setup after stop is invoked
#118626
#120840

The culprit was a missing await of a promise inside setup.
I could simulate this locally by adding a mockFunction in putComponentTemplate to return a Promise.reject:

const mockFunction = () => Promise.reject(new EsErrors.NoLivingConnectionsError());
function putComponentTemplate(...) {
...
  return {
    clusterPromise: retryTransientEsErrors(
      () => mockFunction(),
      { logger }
    ),
    name,
  };
}

In kibana logs verified that server doesn't crash on this error like before, and Fleet setup failed is logged.

[2021-12-09T16:02:20.524+01:00][WARN ][plugins.fleet] Fleet setup failed
[2021-12-09T16:02:20.524+01:00][WARN ][plugins.fleet] NoLivingConnectionsError: Given the configuration, the ConnectionPool was not able to find a usable Connection for this request.
    at mockFunction (/Users/juliabardi/kibana/kibana/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts:207:43)
    at esCall (/Users/juliabardi/kibana/kibana/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts:220:13)
    at retryTransientEsErrors (/Users/juliabardi/kibana/kibana/x-pack/plugins/fleet/server/services/epm/elasticsearch/retry.ts:35:18)
    at retryTransientEsErrors (/Users/juliabardi/kibana/kibana/x-pack/plugins/fleet/server/services/epm/elasticsearch/retry.ts:48:14)
    at ensureDefaultComponentTemplate (/Users/juliabardi/kibana/kibana/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts:342:5)
    at async Promise.all (index 0)
    at ensureFleetGlobalEsAssets (/Users/juliabardi/kibana/kibana/x-pack/plugins/fleet/server/services/setup.ts:141:27)
    at createSetupSideEffects (/Users/juliabardi/kibana/kibana/x-pack/plugins/fleet/server/services/setup.ts:76:5)
    at awaitIfPending (/Users/juliabardi/kibana/kibana/x-pack/plugins/fleet/server/services/setup_utils.ts:30:20)
    at /Users/juliabardi/kibana/kibana/x-pack/plugins/fleet/server/plugin.ts:381:9
[2021-12-09T16:02:20.532+01:00][INFO ][plugins.securitySolution] Dependent plugin setup complete - Starting ManifestTask

@juliaElastic juliaElastic added bug Fixes for quality problems that affect the customer experience v8.0.0 release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed v8.1.0 labels Dec 9, 2021
@juliaElastic juliaElastic self-assigned this Dec 9, 2021
@juliaElastic juliaElastic requested review from a team as code owners December 9, 2021 14:58
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Dec 9, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@@ -341,7 +341,7 @@ export async function ensureDefaultComponentTemplate(
await putComponentTemplate(esClient, logger, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

putComponentTemplate is not returning a promise, but an object containing clusterPromise

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

Good catch 🚀

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

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

cc @juliaElastic

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

LGTM! Nice catch!

@juliaElastic juliaElastic merged commit b5b4ae7 into elastic:main Dec 10, 2021
@juliaElastic juliaElastic deleted the fix-setup-error branch December 10, 2021 07:57
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 10, 2021
@kibanamachine
Copy link
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 Dec 10, 2021
Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 2021
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 bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants