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

[Ingest Manager][EPM] Moving reinstall function outside of promise.all #82672

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion x-pack/plugins/ingest_manager/server/services/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ async function createSetupSideEffects(
ensureInstalledDefaultPackages(soClient, callCluster),
outputService.ensureDefaultOutput(soClient),
agentPolicyService.ensureDefaultAgentPolicy(soClient),
ensurePackagesCompletedInstall(soClient, callCluster),
ensureDefaultIndices(callCluster),
settingsService.getSettings(soClient).catch((e: any) => {
if (e.isBoom && e.output.statusCode === 404) {
Expand All @@ -70,6 +69,14 @@ async function createSetupSideEffects(
}),
]);

// Keeping this outside of the Promise.all because it introduces a race condition.
// If one of the required packages fails to install/upgrade it might get stuck in the installing state.
// On the next call to the /setup API, if there is a upgrade available for one of the required packages a race condition
// will occur between upgrading the package and reinstalling the previously failed package.
// By moving this outside of the Promise.all, the upgrade will occur first, and then we'll attempt to reinstall any
// packages that are stuck in the installing state.
await ensurePackagesCompletedInstall(soClient, callCluster);

// If we just created the default policy, ensure default packages are added to it
if (defaultAgentPolicyCreated) {
const agentPolicyWithPackagePolicies = await agentPolicyService.get(
Expand Down