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 keep policies up to date after package install #174093

Merged
merged 5 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
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
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
Loading