Skip to content

Commit

Permalink
[Fleet] Do not uninstall package on reinstall error (#171880)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Nov 27, 2023
1 parent 750989b commit e7478d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion x-pack/plugins/fleet/server/services/epm/packages/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,16 @@ export async function handleInstallPackageFailure({
// if there is an unknown server error, uninstall any package assets or reinstall the previous version if update
try {
const installType = getInstallType({ pkgVersion, installedPkg });
if (installType === 'install' || installType === 'reinstall') {
if (installType === 'install') {
logger.error(`uninstalling ${pkgkey} after error installing: [${error.toString()}]`);
await removeInstallation({ savedObjectsClient, pkgName, pkgVersion, esClient });
return;
}

if (installType === 'reinstall') {
logger.error(`Failed to reinstall ${pkgkey}: [${error.toString()}]`, { error });
}

await updateInstallStatus({ savedObjectsClient, pkgName, status: 'install_failed' }).catch(
(err) => {
if (!SavedObjectsErrorHelpers.isNotFoundError(err)) {
Expand Down

0 comments on commit e7478d5

Please sign in to comment.