Skip to content

Commit

Permalink
[Fleet] Fix keep policies up to date after package install (#174093)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Jan 3, 2024
1 parent 50a6930 commit 3ce276d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ describe('_installPackage', () => {
soClient.update.mockImplementation(async (type, id, attributes) => {
return { id, attributes } as any;
});
soClient.get.mockImplementation(async (type, id) => {
return { id, attributes: {} } as any;
});

esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
appContextService.start(createAppContextStartContractMock());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export async function _installPackage({
savedObjectType: PACKAGES_SAVED_OBJECT_TYPE,
});
logger.debug(`Package install - Updating install status`);
const updatedPackage = await withPackageSpan('Update install status', () =>
await withPackageSpan('Update install status', () =>
savedObjectsClient.update<Installation>(PACKAGES_SAVED_OBJECT_TYPE, pkgName, {
version: pkgVersion,
install_version: pkgVersion,
Expand All @@ -361,8 +361,13 @@ export async function _installPackage({
),
})
);
logger.debug(`Package install - Install status ${updatedPackage?.attributes?.install_status}`);

// Need to refetch the installation again to retrieve all the attributes
const updatedPackage = await savedObjectsClient.get<Installation>(
PACKAGES_SAVED_OBJECT_TYPE,
pkgName
);
logger.debug(`Package install - Install status ${updatedPackage?.attributes?.install_status}`);
// If the package is flagged with the `keep_policies_up_to_date` flag, upgrade its
// associated package policies after installation
if (updatedPackage.attributes.keep_policies_up_to_date) {
Expand Down

0 comments on commit 3ce276d

Please sign in to comment.