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] Fix isPackageVersionOrLaterInstalled to check for installed package #176532

Merged

Conversation

nchaulet
Copy link
Member

@nchaulet nchaulet commented Feb 8, 2024

Description

Resolve elastic/elastic-agent#4102

Fix isPackageVersionOrLaterInstalled to check for installed package and retry when package is in installing status

Work in progress

Test

The changes are unit tested, I do not think it will be easy/usefull to add an api test here as that scenario happen during some race condition.

You can manually test the race condition by introducing a delay in the intallation
How to reproduce the bug I introduce an artificial delay in the package install process

--- a/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts
+++ b/x-pack/plugins/fleet/server/services/epm/packages/_install_package.ts
@@ -150,6 +150,7 @@ export async function _installPackage({
         spaceId,
         verificationResult,
       });
+      await new Promise((resolve) => setTimeout(resolve, 30 * 1000));
     }
     logger.debug(`Package install - Installing Kibana assets`);
     const kibanaAssetPromise = withPackageSpan('Install Kibana assets', () =>

And try to create two agent policy concurently

Todo

  • unit test for isPackageVersionOrLaterInstalled
  • Should we wrote a release not for that one?

@nchaulet nchaulet self-assigned this Feb 8, 2024
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@nchaulet
Copy link
Member Author

nchaulet commented Feb 8, 2024

/ci

@nchaulet nchaulet added 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 labels Feb 8, 2024
) {
let installType: InstallType;
try {
installType = getInstallType({ pkgVersion, installedPkg: installedPackageObject });
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the installType here as it seems not used by that function consumers, and it seems that function should not return it as it's not creating an install but checking if one exist

@nchaulet nchaulet marked this pull request as ready for review February 8, 2024 18:45
@nchaulet nchaulet requested a review from a team as a code owner February 8, 2024 18:45
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@nchaulet
Copy link
Member Author

nchaulet commented Feb 8, 2024

@elasticmachine merge upstream

Copy link
Member

@kpollich kpollich left a comment

Choose a reason for hiding this comment

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

I'm good with merging this as-is. Happy with the testing approach here. Thanks for tracking this down.

@kpollich
Copy link
Member

kpollich commented Feb 8, 2024

This can probably get a release note fix label and that should suffice for release notes.

@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 @nchaulet

@juliaElastic juliaElastic added release_note:fix and removed release_note:skip Skip the PR/issue when compiling release notes labels Feb 9, 2024
@juliaElastic
Copy link
Contributor

Should this be backported to 8.12?

@nchaulet
Copy link
Member Author

nchaulet commented Feb 9, 2024

Should this be backported to 8.12?

it touch a part of the code that is a little tricky, and the bug it's fixing is only happening in some scenario of race condition not sure it's worth taking the risk to backport it.

@nchaulet nchaulet merged commit 0c1a70e into elastic:main Feb 9, 2024
21 checks passed
@nchaulet nchaulet deleted the feature-fix-isPackageVersionOrLaterInstalled branch February 9, 2024 13:43
@kibanamachine kibanamachine added v8.13.0 backport:skip This commit does not require backporting labels Feb 9, 2024
@kpollich
Copy link
Member

kpollich commented Feb 9, 2024

+1 let's not backport this to be safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting bug Fixes for quality problems that affect the customer experience release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team v8.13.0
Projects
None yet
7 participants