From 64a535d78f68072c50ff73d80da5c223e82e4c80 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Thu, 5 Jun 2025 11:23:51 +0200 Subject: [PATCH 01/24] [Fleet] Save package policy previous revision on package upgrade --- .../current_fields.json | 2 + .../current_mappings.json | 6 + .../fleet/common/experimental_features.ts | 5 +- .../fleet/server/saved_objects/index.ts | 2 + .../server/services/package_policies/utils.ts | 6 +- .../fleet/server/services/package_policy.ts | 134 +++++++++++++++++- .../fleet/server/types/so_attributes.ts | 1 + 7 files changed, 148 insertions(+), 8 deletions(-) diff --git a/packages/kbn-check-mappings-update-cli/current_fields.json b/packages/kbn-check-mappings-update-cli/current_fields.json index 5d7aa4d9d82d0..b5de04e156d00 100644 --- a/packages/kbn-check-mappings-update-cli/current_fields.json +++ b/packages/kbn-check-mappings-update-cli/current_fields.json @@ -550,6 +550,7 @@ "enabled", "inputs", "is_managed", + "latest_revision", "name", "namespace", "output_id", @@ -735,6 +736,7 @@ "enabled", "inputs", "is_managed", + "latest_revision", "name", "namespace", "output_id", diff --git a/packages/kbn-check-mappings-update-cli/current_mappings.json b/packages/kbn-check-mappings-update-cli/current_mappings.json index 78f008fa99a1b..cd16d75f4d4df 100644 --- a/packages/kbn-check-mappings-update-cli/current_mappings.json +++ b/packages/kbn-check-mappings-update-cli/current_mappings.json @@ -1835,6 +1835,9 @@ "is_managed": { "type": "boolean" }, + "latest_revision": { + "type": "boolean" + }, "name": { "type": "keyword" }, @@ -2438,6 +2441,9 @@ "is_managed": { "type": "boolean" }, + "latest_revision": { + "type": "boolean" + }, "name": { "type": "keyword" }, diff --git a/x-pack/platform/plugins/shared/fleet/common/experimental_features.ts b/x-pack/platform/plugins/shared/fleet/common/experimental_features.ts index 0ae2635938f3f..da7edcffeecc6 100644 --- a/x-pack/platform/plugins/shared/fleet/common/experimental_features.ts +++ b/x-pack/platform/plugins/shared/fleet/common/experimental_features.ts @@ -13,8 +13,9 @@ const _allowedExperimentalValues = { enableAutomaticAgentUpgrades: true, enableSyncIntegrationsOnRemote: true, enableSSLSecrets: false, - installedIntegrationsTabularUI: true, - enabledUpgradeAgentlessDeploymentsTask: true, + installedIntegrationsTabularUI: false, + enabledUpgradeAgentlessDeploymentsTask: false, + enablePackageRollback: false, }; /** diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts index 14b27cf102997..99e7d20858f93 100644 --- a/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts +++ b/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts @@ -695,6 +695,7 @@ export const getSavedObjectTypes = ( created_at: { type: 'date' }, created_by: { type: 'keyword' }, bump_agent_policy_revision: { type: 'boolean' }, + latest_revision: { type: 'boolean' }, }, }, modelVersions: { @@ -938,6 +939,7 @@ export const getSavedObjectTypes = ( created_at: { type: 'date' }, created_by: { type: 'keyword' }, bump_agent_policy_revision: { type: 'boolean' }, + latest_revision: { type: 'boolean' }, }, }, modelVersions: { diff --git a/x-pack/platform/plugins/shared/fleet/server/services/package_policies/utils.ts b/x-pack/platform/plugins/shared/fleet/server/services/package_policies/utils.ts index c525e6823e21c..e3388deb5ad66 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/package_policies/utils.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/package_policies/utils.ts @@ -38,7 +38,11 @@ export const mapPackagePolicySavedObjectToPackagePolicy = ({ attributes, namespaces, }: SavedObject): PackagePolicy => { - const { bump_agent_policy_revision: bumpAgentPolicyRevision, ...restAttributes } = attributes; + const { + bump_agent_policy_revision: bumpAgentPolicyRevision, + latest_revision: latestRevision, + ...restAttributes + } = attributes; return { id, version, diff --git a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts index 2b1d3e0491db6..f7fd27325f527 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts @@ -25,6 +25,7 @@ import { SavedObjectsErrorHelpers } from '@kbn/core/server'; import { SavedObjectsUtils } from '@kbn/core/server'; import { v4 as uuidv4 } from 'uuid'; import { load } from 'js-yaml'; +import semverGt from 'semver/functions/gt'; import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common/constants'; @@ -453,6 +454,7 @@ class PackagePolicyClientImpl implements PackagePolicyClient { elasticsearch: { privileges: elasticsearchPrivileges }, }), ...(secretReferences?.length && { secret_references: secretReferences }), + latest_revision: true, revision: 1, created_at: isoDate, created_by: options?.user?.username ?? 'system', @@ -653,6 +655,7 @@ class PackagePolicyClientImpl implements PackagePolicyClient { elasticsearch, policy_id: agentPolicyIdsOfPackagePolicy[0], policy_ids: agentPolicyIdsOfPackagePolicy, + latest_revision: true, revision: 1, created_at: isoDate, created_by: options?.user?.username ?? 'system', @@ -844,12 +847,13 @@ class PackagePolicyClientImpl implements PackagePolicyClient { ); const savedObjectType = await getPackagePolicySavedObjectType(); + const packagePolicyLatestRevisionKuery = `(${savedObjectType}.attributes.latest_revision:true OR NOT ${savedObjectType}.attributes.latest_revision:*)`; const packagePolicySO = await soClient .find({ type: savedObjectType, filter: `${savedObjectType}.attributes.policy_ids:${escapeSearchQueryPhrase( agentPolicyId - )}`, + )} AND ${packagePolicyLatestRevisionKuery}`, perPage: SO_SEARCH_LIMIT, namespaces: isSpacesEnabled ? options.spaceIds : undefined, }) @@ -969,6 +973,14 @@ class PackagePolicyClientImpl implements PackagePolicyClient { )}` ); + const packagePolicyLatestRevisionKuery = `${savedObjectType}.attributes.latest_revision:true OR NOT ${savedObjectType}.attributes.latest_revision:*`; + const filter = _normalizePackagePolicyKuery( + savedObjectType, + kuery + ? `(${packagePolicyLatestRevisionKuery}) AND ${kuery}` + : packagePolicyLatestRevisionKuery + ); + const packagePolicies = await soClient .find({ type: savedObjectType, @@ -977,7 +989,7 @@ class PackagePolicyClientImpl implements PackagePolicyClient { page, perPage, fields, - filter: kuery ? _normalizePackagePolicyKuery(savedObjectType, kuery) : undefined, + filter, namespaces: isSpacesEnabled && options.spaceId ? [options.spaceId] : undefined, }) .catch(catchAndSetErrorStackTrace.withMessage('failed to find package policies')); @@ -1013,6 +1025,8 @@ class PackagePolicyClientImpl implements PackagePolicyClient { ): Promise> { const logger = this.getLogger('listIds'); const { page = 1, perPage = 20, sortField = 'updated_at', sortOrder = 'desc', kuery } = options; + const savedObjectType = await getPackagePolicySavedObjectType(); + const isSpacesEnabled = await isSpaceAwarenessEnabled(); logger.debug( () => @@ -1021,8 +1035,14 @@ class PackagePolicyClientImpl implements PackagePolicyClient { )}]` ); - const savedObjectType = await getPackagePolicySavedObjectType(); - const isSpacesEnabled = await isSpaceAwarenessEnabled(); + const packagePolicyLatestRevisionKuery = `${savedObjectType}.attributes.latest_revision:true OR NOT ${savedObjectType}.attributes.latest_revision:*`; + const filter = _normalizePackagePolicyKuery( + savedObjectType, + kuery + ? `(${packagePolicyLatestRevisionKuery}) AND ${kuery}` + : packagePolicyLatestRevisionKuery + ); + const packagePolicies = await soClient .find<{ name: string }>({ type: savedObjectType, @@ -1031,7 +1051,7 @@ class PackagePolicyClientImpl implements PackagePolicyClient { page, perPage, fields: ['name'], - filter: kuery ? _normalizePackagePolicyKuery(savedObjectType, kuery) : undefined, + filter, namespaces: isSpacesEnabled ? options.spaceIds : undefined, }) .catch(catchAndSetErrorStackTrace.withMessage('failed to find package policies IDs')); @@ -1210,6 +1230,51 @@ class PackagePolicyClientImpl implements PackagePolicyClient { packagePolicy: restOfPackagePolicy, }); + // If the package version has increased, save the previous package policy revision. + if ( + appContextService.getExperimentalFeatures().enablePackageRollback && + packagePolicy.package && + oldPackagePolicy.package && + semverGt(packagePolicy.package.version, oldPackagePolicy.package.version) + ) { + logger.debug( + `Saving previous revision of package policy ${id} with package version ${oldPackagePolicy.version}` + ); + const currentPackagePolicySO = await soClient.get( + savedObjectType, + id + ); + const previousRevisionSO = { + ...currentPackagePolicySO, + id: `${id}:prev`, + attributes: { + ...currentPackagePolicySO.attributes, + latest_revision: false, + }, + }; + try { + await soClient.get(savedObjectType, `${id}:prev`); + await soClient.update( + savedObjectType, + `${id}:prev`, + previousRevisionSO.attributes + ); + } catch (error) { + if (error.output.statusCode === 404) { + await soClient.create( + savedObjectType, + previousRevisionSO.attributes, + { + id: `${id}:prev`, + references: currentPackagePolicySO.references, + } + ); + } else { + throw error; + } + } + } + logger.debug(`Updating SO with revision ${oldPackagePolicy.revision + 1}`); await soClient .update( @@ -1391,6 +1456,12 @@ class PackagePolicyClientImpl implements PackagePolicyClient { packagePolicy: NewPackagePolicyWithId; error: Error | SavedObjectError; }> = []; + const previousPolicyRevisionsToCreate: Array< + SavedObjectsBulkCreateObject + > = []; + const previousPolicyRevisionsToUpdate: Array< + SavedObjectsBulkUpdateObject + > = []; const secretStorageEnabled = await isSecretStorageEnabled(esClient, soClient); @@ -1430,6 +1501,40 @@ class PackagePolicyClientImpl implements PackagePolicyClient { this.keepPolicyIdInSync(oldPackagePolicy); } + // If the package version has increased, save the previous package policy revision. + if ( + appContextService.getExperimentalFeatures().enablePackageRollback && + packagePolicy.package && + oldPackagePolicy.package && + semverGt(packagePolicy.package.version, oldPackagePolicy.package.version) + ) { + logger.debug( + `Saving previous revision of package policy ${id} with package version ${oldPackagePolicy.version}` + ); + const currentPackagePolicySO = await soClient.get( + savedObjectType, + id + ); + const previousRevisionSO = { + ...currentPackagePolicySO, + id: `${id}:prev`, + attributes: { + ...currentPackagePolicySO.attributes, + latest_revision: false, + }, + }; + try { + await soClient.get(savedObjectType, `${id}:prev`); + previousPolicyRevisionsToUpdate.push(previousRevisionSO); + } catch (error) { + if (error.output.statusCode === 404) { + previousPolicyRevisionsToCreate.push(previousRevisionSO); + } else { + throw error; + } + } + } + let secretReferences: PolicySecretReference[] | undefined; const { version } = packagePolicyUpdate; @@ -1555,6 +1660,25 @@ class PackagePolicyClientImpl implements PackagePolicyClient { } }); + // Store previous revision. + if (appContextService.getExperimentalFeatures().enablePackageRollback) { + await soClient + .bulkCreate(previousPolicyRevisionsToCreate) + .catch( + catchAndSetErrorStackTrace.withMessage( + 'Saved objects bulk create of previous package policy revisions failed' + ) + ); + await soClient + .bulkUpdate(previousPolicyRevisionsToUpdate) + .catch( + catchAndSetErrorStackTrace.withMessage( + 'Saved objects bulk update of previous package policy revisions failed' + ) + ); + } + + // Update package policies SO. const { saved_objects: updatedPolicies } = await soClient .bulkUpdate(policiesToUpdate) .catch(catchAndSetErrorStackTrace.withMessage(`Saved objects bulk update failed]`)); diff --git a/x-pack/platform/plugins/shared/fleet/server/types/so_attributes.ts b/x-pack/platform/plugins/shared/fleet/server/types/so_attributes.ts index ee111a90536c1..7fd3ec12c50b7 100644 --- a/x-pack/platform/plugins/shared/fleet/server/types/so_attributes.ts +++ b/x-pack/platform/plugins/shared/fleet/server/types/so_attributes.ts @@ -148,6 +148,7 @@ export interface PackagePolicySOAttributes { agents?: number; overrides?: any | null; bump_agent_policy_revision?: boolean; + latest_revision?: boolean; } interface OutputSoBaseAttributes { From bf592c180ef7d60ca88b69732a2fc9211b50d382 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 5 Jun 2025 10:01:24 +0000 Subject: [PATCH 02/24] [CI] Auto-commit changed files from 'node scripts/jest_integration -u src/core/server/integration_tests/ci_checks' --- .../ci_checks/saved_objects/check_registered_types.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts index 44a72791aae29..db685ec1379bd 100644 --- a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts +++ b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts @@ -113,7 +113,7 @@ describe('checking migration metadata changes on all registered SO types', () => "fleet-agent-policies": "f69f7c5639f4cf9e85077c904e161f3574ac3ca2", "fleet-fleet-server-host": "232d98738d5321b86edc426e21a9ca2f607da999", "fleet-message-signing-keys": "93421f43fed2526b59092a4e3c65d64bc2266c0f", - "fleet-package-policies": "b1ded996118af658bc420a737ff3c4d784641fc7", + "fleet-package-policies": "c4e22a7a3600024ed2a1709939128b5a47fb0723", "fleet-preconfiguration-deletion-record": "c52ea1e13c919afe8a5e8e3adbb7080980ecc08e", "fleet-proxy": "6cb688f0d2dd856400c1dbc998b28704ff70363d", "fleet-setup-lock": "0dc784792c79b5af5a6e6b5dcac06b0dbaa90bde", @@ -129,7 +129,7 @@ describe('checking migration metadata changes on all registered SO types', () => "ingest-agent-policies": "cfe66f4aeca8f53b26bd4ddb0e956de1637d774e", "ingest-download-sources": "5be99940d6b5f9121b2fd279708d14e2bc0bde26", "ingest-outputs": "6743521f501bd77b1523dbb1df48d7c47fdad529", - "ingest-package-policies": "6a80000fdf2544f2485b0c6a51ecc434b6a12987", + "ingest-package-policies": "04aa783f512ee19ab8883d47d532a37b2470dbf4", "ingest_manager_settings": "111a616eb72627c002029c19feb9e6c439a10505", "intercept_interaction_record": "13587751af378409df5cadd08aeb0d3884b1645a", "intercept_trigger_record": "9223039379bf9997781ad91df120eb360c3e6b77", From 4e52fec7e6c2abcd0eae7d95803d6f7c715bd1c7 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Thu, 5 Jun 2025 14:56:28 +0200 Subject: [PATCH 03/24] Feedback --- .../fleet/server/saved_objects/index.ts | 29 +++++++++ ...ge_policy_latest_revision_backfill.test.ts | 63 +++++++++++++++++++ ...package_policy_latest_revision_backfill.ts | 21 +++++++ .../fleet/server/services/package_policy.ts | 13 ++-- 4 files changed, 118 insertions(+), 8 deletions(-) create mode 100644 x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/package_policy_latest_revision_backfill.test.ts create mode 100644 x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/package_policy_latest_revision_backfill.ts diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts index 99e7d20858f93..ce7f6adb19e9a 100644 --- a/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts +++ b/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts @@ -103,6 +103,7 @@ import { import { backfillAgentPolicyToV4 } from './model_versions/agent_policy_v4'; import { backfillOutputPolicyToV7 } from './model_versions/outputs'; import { packagePolicyV17AdvancedFieldsForEndpointV818 } from './model_versions/security_solution/v17_advanced_package_policy_fields'; +import { backfillPackagePolicyLatestRevision } from './model_versions/package_policy_latest_revision_backfill'; /* * Saved object types and mappings @@ -876,6 +877,20 @@ export const getSavedObjectTypes = ( }, ], }, + '19': { + changes: [ + { + type: 'mappings_addition', + addedMappings: { + latest_revision: { type: 'boolean' }, + }, + }, + { + type: 'data_backfill', + backfillFn: backfillPackagePolicyLatestRevision, + }, + ], + }, }, migrations: { '7.10.0': migratePackagePolicyToV7100, @@ -979,6 +994,20 @@ export const getSavedObjectTypes = ( }, ], }, + '5': { + changes: [ + { + type: 'mappings_addition', + addedMappings: { + latest_revision: { type: 'boolean' }, + }, + }, + { + type: 'data_backfill', + backfillFn: backfillPackagePolicyLatestRevision, + }, + ], + }, }, }, [PACKAGES_SAVED_OBJECT_TYPE]: { diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/package_policy_latest_revision_backfill.test.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/package_policy_latest_revision_backfill.test.ts new file mode 100644 index 0000000000000..c173ebcd32f54 --- /dev/null +++ b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/package_policy_latest_revision_backfill.test.ts @@ -0,0 +1,63 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { + SavedObject, + SavedObjectModelTransformationContext, +} from '@kbn/core-saved-objects-server'; + +import type { PackagePolicy } from '../../../common'; + +import { backfillPackagePolicyLatestRevision } from './package_policy_latest_revision_backfill'; + +describe('backfillPackagePolicyLatestRevision', () => { + const packagePolicyDoc: SavedObject = { + id: 'policy1', + type: 'ingest-package-policies', + references: [], + attributes: { + id: 'policy1', + name: 'Policy 1', + namespace: 'default', + description: '', + policy_id: 'policy1', + policy_ids: ['policy1'], + package: { name: 'test-package', version: '1.0.0', title: 'Test Package' }, + inputs: [], + revision: 1, + updated_at: '2021-08-17T14:00:00.000Z', + updated_by: 'elastic', + created_at: '2021-08-17T14:00:00.000Z', + created_by: 'elastic', + enabled: true, + }, + }; + + it('should set latest_revision to true if not defined', () => { + const migratedPackagePolicyDoc = backfillPackagePolicyLatestRevision( + packagePolicyDoc, + {} as SavedObjectModelTransformationContext + ); + + expect(migratedPackagePolicyDoc.attributes.latest_revision).toBe(true); + }); + + it('should not change latest_revision if already defined', () => { + const migratedPackagePolicyDoc = backfillPackagePolicyLatestRevision( + { + ...packagePolicyDoc, + attributes: { + ...packagePolicyDoc.attributes, + latest_revision: false, + }, + }, + {} as SavedObjectModelTransformationContext + ); + + expect(migratedPackagePolicyDoc.attributes.latest_revision).toBe(false); + }); +}); diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/package_policy_latest_revision_backfill.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/package_policy_latest_revision_backfill.ts new file mode 100644 index 0000000000000..5d893872c054e --- /dev/null +++ b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/package_policy_latest_revision_backfill.ts @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { SavedObjectModelDataBackfillFn } from '@kbn/core-saved-objects-server'; + +import type { PackagePolicy } from '../../../common'; + +export const backfillPackagePolicyLatestRevision: SavedObjectModelDataBackfillFn< + PackagePolicy & { latest_revision?: boolean }, + PackagePolicy & { latest_revision?: boolean } +> = (packagePolicyDoc) => { + if (packagePolicyDoc.attributes.latest_revision === undefined) { + packagePolicyDoc.attributes.latest_revision = true; + } + + return packagePolicyDoc; +}; diff --git a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts index f7fd27325f527..1668b6c348643 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts @@ -847,13 +847,12 @@ class PackagePolicyClientImpl implements PackagePolicyClient { ); const savedObjectType = await getPackagePolicySavedObjectType(); - const packagePolicyLatestRevisionKuery = `(${savedObjectType}.attributes.latest_revision:true OR NOT ${savedObjectType}.attributes.latest_revision:*)`; const packagePolicySO = await soClient .find({ type: savedObjectType, filter: `${savedObjectType}.attributes.policy_ids:${escapeSearchQueryPhrase( agentPolicyId - )} AND ${packagePolicyLatestRevisionKuery}`, + )} AND ${savedObjectType}.attributes.latest_revision:true`, perPage: SO_SEARCH_LIMIT, namespaces: isSpacesEnabled ? options.spaceIds : undefined, }) @@ -973,12 +972,11 @@ class PackagePolicyClientImpl implements PackagePolicyClient { )}` ); - const packagePolicyLatestRevisionKuery = `${savedObjectType}.attributes.latest_revision:true OR NOT ${savedObjectType}.attributes.latest_revision:*`; const filter = _normalizePackagePolicyKuery( savedObjectType, kuery - ? `(${packagePolicyLatestRevisionKuery}) AND ${kuery}` - : packagePolicyLatestRevisionKuery + ? `${savedObjectType}.attributes.latest_revision:true AND ${kuery}` + : `${savedObjectType}.attributes.latest_revision:true` ); const packagePolicies = await soClient @@ -1035,12 +1033,11 @@ class PackagePolicyClientImpl implements PackagePolicyClient { )}]` ); - const packagePolicyLatestRevisionKuery = `${savedObjectType}.attributes.latest_revision:true OR NOT ${savedObjectType}.attributes.latest_revision:*`; const filter = _normalizePackagePolicyKuery( savedObjectType, kuery - ? `(${packagePolicyLatestRevisionKuery}) AND ${kuery}` - : packagePolicyLatestRevisionKuery + ? `${savedObjectType}.attributes.latest_revision:true AND ${kuery}` + : `${savedObjectType}.attributes.latest_revision:true` ); const packagePolicies = await soClient From d7efcc54b0b760773495044afdb071f2ab5812e7 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 5 Jun 2025 15:47:42 +0000 Subject: [PATCH 04/24] [CI] Auto-commit changed files from 'node scripts/jest_integration -u src/core/server/integration_tests/ci_checks' --- .../ci_checks/saved_objects/check_registered_types.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts index db685ec1379bd..f6923f85b2344 100644 --- a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts +++ b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts @@ -113,7 +113,7 @@ describe('checking migration metadata changes on all registered SO types', () => "fleet-agent-policies": "f69f7c5639f4cf9e85077c904e161f3574ac3ca2", "fleet-fleet-server-host": "232d98738d5321b86edc426e21a9ca2f607da999", "fleet-message-signing-keys": "93421f43fed2526b59092a4e3c65d64bc2266c0f", - "fleet-package-policies": "c4e22a7a3600024ed2a1709939128b5a47fb0723", + "fleet-package-policies": "efd05a0ed95f387cecf0fad8902c482a5732668b", "fleet-preconfiguration-deletion-record": "c52ea1e13c919afe8a5e8e3adbb7080980ecc08e", "fleet-proxy": "6cb688f0d2dd856400c1dbc998b28704ff70363d", "fleet-setup-lock": "0dc784792c79b5af5a6e6b5dcac06b0dbaa90bde", @@ -129,7 +129,7 @@ describe('checking migration metadata changes on all registered SO types', () => "ingest-agent-policies": "cfe66f4aeca8f53b26bd4ddb0e956de1637d774e", "ingest-download-sources": "5be99940d6b5f9121b2fd279708d14e2bc0bde26", "ingest-outputs": "6743521f501bd77b1523dbb1df48d7c47fdad529", - "ingest-package-policies": "04aa783f512ee19ab8883d47d532a37b2470dbf4", + "ingest-package-policies": "cb7e5f23e0af62f2d66e194ad2b108c9645e422c", "ingest_manager_settings": "111a616eb72627c002029c19feb9e6c439a10505", "intercept_interaction_record": "13587751af378409df5cadd08aeb0d3884b1645a", "intercept_trigger_record": "9223039379bf9997781ad91df120eb360c3e6b77", From 7157e404b06d89c4a7a403fd952be6fbf8c216a1 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Thu, 5 Jun 2025 18:11:29 +0200 Subject: [PATCH 05/24] Save previous package SO --- .../server/services/epm/packages/install.ts | 30 +++++++++++++++++++ .../fleet/server/services/package_policy.ts | 2 -- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts index 4da04ef1ae313..30da7355099be 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts @@ -1136,6 +1136,36 @@ export async function restartInstallation(options: { savedObjectType: PACKAGES_SAVED_OBJECT_TYPE, }); + if (appContextService.getExperimentalFeatures().enablePackageRollback) { + const currentInstallation = await savedObjectsClient.get( + PACKAGES_SAVED_OBJECT_TYPE, + pkgName + ); + const previousVersionSO = { + ...currentInstallation, + id: `${pkgName}:prev`, + }; + try { + await savedObjectsClient.update( + PACKAGES_SAVED_OBJECT_TYPE, + `${pkgName}:prev`, + previousVersionSO.attributes + ); + } catch (e) { + if (e.output.statusCode === 404) { + await savedObjectsClient.create( + PACKAGES_SAVED_OBJECT_TYPE, + previousVersionSO.attributes, + { + id: `${pkgName}:prev`, + } + ); + } else { + throw e; + } + } + } + await savedObjectsClient.update(PACKAGES_SAVED_OBJECT_TYPE, pkgName, savedObjectUpdate); } diff --git a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts index 1668b6c348643..7c6645b0fec5b 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts @@ -1250,7 +1250,6 @@ class PackagePolicyClientImpl implements PackagePolicyClient { }, }; try { - await soClient.get(savedObjectType, `${id}:prev`); await soClient.update( savedObjectType, `${id}:prev`, @@ -1263,7 +1262,6 @@ class PackagePolicyClientImpl implements PackagePolicyClient { previousRevisionSO.attributes, { id: `${id}:prev`, - references: currentPackagePolicySO.references, } ); } else { From 7c68f6062e4849265456619e5867609d49591123 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Wed, 11 Jun 2025 15:47:48 +0200 Subject: [PATCH 06/24] Fix package revision save --- .../current_fields.json | 18 ++---------------- .../current_mappings.json | 5 ++++- .../shared/fleet/common/types/models/epm.ts | 1 + .../shared/fleet/server/saved_objects/index.ts | 11 +++++++++++ .../fleet/server/services/epm/packages/get.ts | 1 + .../server/services/epm/packages/install.ts | 5 +++++ 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/kbn-check-mappings-update-cli/current_fields.json b/packages/kbn-check-mappings-update-cli/current_fields.json index b5de04e156d00..31e3df6042cd5 100644 --- a/packages/kbn-check-mappings-update-cli/current_fields.json +++ b/packages/kbn-check-mappings-update-cli/current_fields.json @@ -313,12 +313,9 @@ "enabled", "error", "filter", - "indexPattern", "integrationName", "managed", "matchers", - "matchers.fields", - "matchers.values", "name", "type" ], @@ -371,6 +368,7 @@ "keep_policies_up_to_date", "latest_executed_state", "latest_install_failed_attempts", + "latest_version", "name", "package_assets", "verification_key_id", @@ -843,19 +841,7 @@ "job.job_id", "model_id" ], - "monitoring-entity-source": [ - "enabled", - "error", - "filter", - "indexPattern", - "integrationName", - "managed", - "matchers", - "matchers.fields", - "matchers.values", - "name", - "type" - ], + "monitoring-entity-source": [], "monitoring-telemetry": [ "reportedClusterUuids" ], diff --git a/packages/kbn-check-mappings-update-cli/current_mappings.json b/packages/kbn-check-mappings-update-cli/current_mappings.json index cd16d75f4d4df..15d168e076d2b 100644 --- a/packages/kbn-check-mappings-update-cli/current_mappings.json +++ b/packages/kbn-check-mappings-update-cli/current_mappings.json @@ -1079,7 +1079,7 @@ "managed": { "type": "boolean" }, - "matchers": { + "matchers": { "dynamic": false, "type": "object" }, @@ -1249,6 +1249,9 @@ "enabled": false, "type": "object" }, + "latest_version": { + "type": "boolean" + }, "name": { "type": "keyword" }, diff --git a/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts b/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts index d341259aea0cf..ec2c0db85d44c 100644 --- a/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts +++ b/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts @@ -684,6 +684,7 @@ export interface Installation { latest_uninstall_failed_attempts?: FailedAttempt[]; latest_executed_state?: InstallLatestExecutedState; latest_custom_asset_install_failed_attempts?: { [asset: string]: CustomAssetFailedAttempt }; + latest_version?: boolean; } export interface PackageUsageStats { diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts index ce7f6adb19e9a..6ec847d688fbe 100644 --- a/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts +++ b/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts @@ -1074,6 +1074,7 @@ export const getSavedObjectTypes = ( }, }, }, + latest_version: { type: 'boolean' }, }, }, modelVersions: { @@ -1108,6 +1109,16 @@ export const getSavedObjectTypes = ( ], }, '4': { + changes: [ + { + type: 'mappings_addition', + addedMappings: { + latest_version: { type: 'boolean' }, + }, + }, + ], + }, + '5': { changes: [ { type: 'mappings_addition', diff --git a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/get.ts b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/get.ts index f7cbc87b8ca2c..75fbce7564e07 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/get.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/get.ts @@ -308,6 +308,7 @@ export async function getPackageSavedObjects( ...(options || {}), type: PACKAGES_SAVED_OBJECT_TYPE, perPage: SO_SEARCH_LIMIT, + filter: `${PACKAGES_SAVED_OBJECT_TYPE}.attributes.latest_version: true`, }); for (const savedObject of result.saved_objects) { diff --git a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts index 30da7355099be..db3c069986d20 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts @@ -1144,6 +1144,10 @@ export async function restartInstallation(options: { const previousVersionSO = { ...currentInstallation, id: `${pkgName}:prev`, + attributes: { + ...currentInstallation.attributes, + latest_version: false, + }, }; try { await savedObjectsClient.update( @@ -1206,6 +1210,7 @@ export async function createInstallation(options: { install_format_schema_version: FLEET_INSTALL_FORMAT_VERSION, keep_policies_up_to_date: defaultKeepPoliciesUpToDate, verification_status: 'unknown', + latest_version: true, }; if (verificationResult) { From 7a4ce886a90b5969167a795d9c55d526fd6f22f9 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:35:23 +0000 Subject: [PATCH 07/24] [CI] Auto-commit changed files from 'node scripts/capture_oas_snapshot --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/streams --include-path /api/fleet --include-path /api/dashboards --include-path /api/saved_objects/_import --include-path /api/saved_objects/_export --include-path /api/maintenance_window --update' --- oas_docs/bundle.json | 454 -------------------------------- oas_docs/bundle.serverless.json | 454 -------------------------------- 2 files changed, 908 deletions(-) diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index e7fb43de94def..d52f8257ea256 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -26252,460 +26252,6 @@ ] } }, - "/api/fleet/epm/packages/_bulk_uninstall": { - "post": { - "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", - "operationId": "post-fleet-epm-packages-bulk-uninstall", - "parameters": [ - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "force": { - "default": false, - "type": "boolean" - }, - "packages": { - "items": { - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - } - }, - "required": [ - "name", - "version" - ], - "type": "object" - }, - "minItems": 1, - "type": "array" - } - }, - "required": [ - "packages" - ], - "type": "object" - } - } - } - }, - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "taskId": { - "type": "string" - } - }, - "required": [ - "taskId" - ], - "type": "object" - } - } - } - }, - "400": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "description": "Generic Error", - "properties": { - "attributes": {}, - "error": { - "type": "string" - }, - "errorType": { - "type": "string" - }, - "message": { - "type": "string" - }, - "statusCode": { - "type": "number" - } - }, - "required": [ - "message", - "attributes" - ], - "type": "object" - } - } - } - } - }, - "summary": "Bulk uninstall packages", - "tags": [ - "Elastic Package Manager (EPM)" - ] - } - }, - "/api/fleet/epm/packages/_bulk_uninstall/{taskId}": { - "get": { - "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", - "operationId": "get-fleet-epm-packages-bulk-uninstall-taskid", - "parameters": [ - { - "in": "path", - "name": "taskId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - }, - "results": { - "items": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - }, - "name": { - "type": "string" - }, - "success": { - "type": "boolean" - } - }, - "required": [ - "name", - "success" - ], - "type": "object" - }, - "type": "array" - }, - "status": { - "type": "string" - } - }, - "required": [ - "status" - ], - "type": "object" - } - } - } - }, - "400": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "description": "Generic Error", - "properties": { - "attributes": {}, - "error": { - "type": "string" - }, - "errorType": { - "type": "string" - }, - "message": { - "type": "string" - }, - "statusCode": { - "type": "number" - } - }, - "required": [ - "message", - "attributes" - ], - "type": "object" - } - } - } - } - }, - "summary": "Get Bulk uninstall packages details", - "tags": [ - "Elastic Package Manager (EPM)" - ] - } - }, - "/api/fleet/epm/packages/_bulk_upgrade": { - "post": { - "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", - "operationId": "post-fleet-epm-packages-bulk-upgrade", - "parameters": [ - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "force": { - "default": false, - "type": "boolean" - }, - "packages": { - "items": { - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - } - }, - "required": [ - "name" - ], - "type": "object" - }, - "minItems": 1, - "type": "array" - }, - "prerelease": { - "type": "boolean" - }, - "upgrade_package_policies": { - "default": false, - "type": "boolean" - } - }, - "required": [ - "packages" - ], - "type": "object" - } - } - } - }, - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "taskId": { - "type": "string" - } - }, - "required": [ - "taskId" - ], - "type": "object" - } - } - } - }, - "400": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "description": "Generic Error", - "properties": { - "attributes": {}, - "error": { - "type": "string" - }, - "errorType": { - "type": "string" - }, - "message": { - "type": "string" - }, - "statusCode": { - "type": "number" - } - }, - "required": [ - "message", - "attributes" - ], - "type": "object" - } - } - } - } - }, - "summary": "Bulk upgrade packages", - "tags": [ - "Elastic Package Manager (EPM)" - ] - } - }, - "/api/fleet/epm/packages/_bulk_upgrade/{taskId}": { - "get": { - "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", - "operationId": "get-fleet-epm-packages-bulk-upgrade-taskid", - "parameters": [ - { - "in": "path", - "name": "taskId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - }, - "results": { - "items": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - }, - "name": { - "type": "string" - }, - "success": { - "type": "boolean" - } - }, - "required": [ - "name", - "success" - ], - "type": "object" - }, - "type": "array" - }, - "status": { - "type": "string" - } - }, - "required": [ - "status" - ], - "type": "object" - } - } - } - }, - "400": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "description": "Generic Error", - "properties": { - "attributes": {}, - "error": { - "type": "string" - }, - "errorType": { - "type": "string" - }, - "message": { - "type": "string" - }, - "statusCode": { - "type": "number" - } - }, - "required": [ - "message", - "attributes" - ], - "type": "object" - } - } - } - } - }, - "summary": "Get Bulk upgrade packages details", - "tags": [ - "Elastic Package Manager (EPM)" - ] - } - }, "/api/fleet/epm/packages/installed": { "get": { "description": "[Required authorization] Route required privileges: integrations-read OR fleet-setup OR fleet-all.", diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index 13cb962947708..ee7272819a72b 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -26252,460 +26252,6 @@ ] } }, - "/api/fleet/epm/packages/_bulk_uninstall": { - "post": { - "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", - "operationId": "post-fleet-epm-packages-bulk-uninstall", - "parameters": [ - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "force": { - "default": false, - "type": "boolean" - }, - "packages": { - "items": { - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - } - }, - "required": [ - "name", - "version" - ], - "type": "object" - }, - "minItems": 1, - "type": "array" - } - }, - "required": [ - "packages" - ], - "type": "object" - } - } - } - }, - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "taskId": { - "type": "string" - } - }, - "required": [ - "taskId" - ], - "type": "object" - } - } - } - }, - "400": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "description": "Generic Error", - "properties": { - "attributes": {}, - "error": { - "type": "string" - }, - "errorType": { - "type": "string" - }, - "message": { - "type": "string" - }, - "statusCode": { - "type": "number" - } - }, - "required": [ - "message", - "attributes" - ], - "type": "object" - } - } - } - } - }, - "summary": "Bulk uninstall packages", - "tags": [ - "Elastic Package Manager (EPM)" - ] - } - }, - "/api/fleet/epm/packages/_bulk_uninstall/{taskId}": { - "get": { - "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", - "operationId": "get-fleet-epm-packages-bulk-uninstall-taskid", - "parameters": [ - { - "in": "path", - "name": "taskId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - }, - "results": { - "items": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - }, - "name": { - "type": "string" - }, - "success": { - "type": "boolean" - } - }, - "required": [ - "name", - "success" - ], - "type": "object" - }, - "type": "array" - }, - "status": { - "type": "string" - } - }, - "required": [ - "status" - ], - "type": "object" - } - } - } - }, - "400": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "description": "Generic Error", - "properties": { - "attributes": {}, - "error": { - "type": "string" - }, - "errorType": { - "type": "string" - }, - "message": { - "type": "string" - }, - "statusCode": { - "type": "number" - } - }, - "required": [ - "message", - "attributes" - ], - "type": "object" - } - } - } - } - }, - "summary": "Get Bulk uninstall packages details", - "tags": [ - "Elastic Package Manager (EPM)" - ] - } - }, - "/api/fleet/epm/packages/_bulk_upgrade": { - "post": { - "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", - "operationId": "post-fleet-epm-packages-bulk-upgrade", - "parameters": [ - { - "description": "A required header to protect against CSRF attacks", - "in": "header", - "name": "kbn-xsrf", - "required": true, - "schema": { - "example": "true", - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "force": { - "default": false, - "type": "boolean" - }, - "packages": { - "items": { - "additionalProperties": false, - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - } - }, - "required": [ - "name" - ], - "type": "object" - }, - "minItems": 1, - "type": "array" - }, - "prerelease": { - "type": "boolean" - }, - "upgrade_package_policies": { - "default": false, - "type": "boolean" - } - }, - "required": [ - "packages" - ], - "type": "object" - } - } - } - }, - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "taskId": { - "type": "string" - } - }, - "required": [ - "taskId" - ], - "type": "object" - } - } - } - }, - "400": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "description": "Generic Error", - "properties": { - "attributes": {}, - "error": { - "type": "string" - }, - "errorType": { - "type": "string" - }, - "message": { - "type": "string" - }, - "statusCode": { - "type": "number" - } - }, - "required": [ - "message", - "attributes" - ], - "type": "object" - } - } - } - } - }, - "summary": "Bulk upgrade packages", - "tags": [ - "Elastic Package Manager (EPM)" - ] - } - }, - "/api/fleet/epm/packages/_bulk_upgrade/{taskId}": { - "get": { - "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", - "operationId": "get-fleet-epm-packages-bulk-upgrade-taskid", - "parameters": [ - { - "in": "path", - "name": "taskId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - }, - "results": { - "items": { - "additionalProperties": false, - "properties": { - "error": { - "additionalProperties": false, - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - }, - "name": { - "type": "string" - }, - "success": { - "type": "boolean" - } - }, - "required": [ - "name", - "success" - ], - "type": "object" - }, - "type": "array" - }, - "status": { - "type": "string" - } - }, - "required": [ - "status" - ], - "type": "object" - } - } - } - }, - "400": { - "content": { - "application/json": { - "schema": { - "additionalProperties": false, - "description": "Generic Error", - "properties": { - "attributes": {}, - "error": { - "type": "string" - }, - "errorType": { - "type": "string" - }, - "message": { - "type": "string" - }, - "statusCode": { - "type": "number" - } - }, - "required": [ - "message", - "attributes" - ], - "type": "object" - } - } - } - } - }, - "summary": "Get Bulk upgrade packages details", - "tags": [ - "Elastic Package Manager (EPM)" - ] - } - }, "/api/fleet/epm/packages/installed": { "get": { "description": "[Required authorization] Route required privileges: integrations-read OR fleet-setup OR fleet-all.", From 0acc2c9fb676721fc29308fcc9deb8cda603b629 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:40:03 +0000 Subject: [PATCH 08/24] [CI] Auto-commit changed files from 'node scripts/jest_integration -u src/core/server/integration_tests/ci_checks' --- .../ci_checks/saved_objects/check_registered_types.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts index f6923f85b2344..cae2af2f8b898 100644 --- a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts +++ b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts @@ -100,7 +100,7 @@ describe('checking migration metadata changes on all registered SO types', () => "entity-definition": "1c6bff35c423d5dc5650bc806cf2899e4706a0bc", "entity-discovery-api-key": "c267a65c69171d1804362155c1378365f5acef88", "entity-engine-status": "09f6a617020708e4f638137e5ef35bd9534133be", - "epm-packages": "5a9f55e38d424f5b5ebbfeac802788b5b05d867f", + "epm-packages": "a0b5685bb4644957d975421d9fd0d3b1b6a8c944", "epm-packages-assets": "7a3e58efd9a14191d0d1a00b8aaed30a145fd0b1", "event-annotation-group": "715ba867d8c68f3c9438052210ea1c30a9362582", "event_loop_delays_daily": "01b967e8e043801357503de09199dfa3853bab88", From e710b9ab0caae386e98b209a18928f86738fa7e7 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Wed, 11 Jun 2025 16:48:02 +0200 Subject: [PATCH 09/24] Add package SO backfill --- ...stallation_latest_version_backfill.test.ts | 59 +++++++++++++++++++ .../installation_latest_version_backfill.ts | 21 +++++++ 2 files changed, 80 insertions(+) create mode 100644 x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.test.ts create mode 100644 x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.ts diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.test.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.test.ts new file mode 100644 index 0000000000000..862f410e5ab0c --- /dev/null +++ b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.test.ts @@ -0,0 +1,59 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { + SavedObject, + SavedObjectModelTransformationContext, +} from '@kbn/core-saved-objects-server'; + +import type { Installation } from '../../../common'; + +import { backfillInstallationLatestVersion } from './installation_latest_version_backfill'; + +describe('backfillInstallationLatestVersion', () => { + const doc: SavedObject = { + id: 'my-package', + type: 'epm-packages', + references: [], + attributes: { + installed_kibana: [], + installed_es: [], + name: 'my-package', + version: '1.0.0', + install_status: 'installed', + install_version: '1.0.0', + install_started_at: '2023-10-01T00:00:00.000Z', + install_source: 'registry', + es_index_patterns: {}, + verification_status: 'verified', + }, + }; + + it('should set latest_revision to true if not defined', () => { + const migratedDoc = backfillInstallationLatestVersion( + doc, + {} as SavedObjectModelTransformationContext + ); + + expect(migratedDoc.attributes.latest_version).toBe(true); + }); + + it('should not change latest_revision if already defined', () => { + const migratedDoc = backfillInstallationLatestVersion( + { + ...doc, + attributes: { + ...doc.attributes, + latest_version: false, + }, + }, + {} as SavedObjectModelTransformationContext + ); + + expect(migratedDoc.attributes.latest_version).toBe(false); + }); +}); diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.ts new file mode 100644 index 0000000000000..b0244227f1147 --- /dev/null +++ b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.ts @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { SavedObjectModelDataBackfillFn } from '@kbn/core-saved-objects-server'; + +import type { Installation } from '../../../common'; + +export const backfillInstallationLatestVersion: SavedObjectModelDataBackfillFn< + Installation, + Installation +> = (doc) => { + if (doc.attributes.latest_version === undefined) { + doc.attributes.latest_version = true; + } + + return doc; +}; From d01d8438cf622d6bfa8114d4ccf902d814f00f5f Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 11 Jun 2025 15:16:38 +0000 Subject: [PATCH 10/24] [CI] Auto-commit changed files from 'make api-docs' --- oas_docs/output/kibana.serverless.yaml | 298 ------------------------- oas_docs/output/kibana.yaml | 298 ------------------------- 2 files changed, 596 deletions(-) diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index d99830440d591..4bb4be16b9366 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -27177,304 +27177,6 @@ paths: summary: Bulk install packages tags: - Elastic Package Manager (EPM) - /api/fleet/epm/packages/_bulk_uninstall: - post: - description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' - operationId: post-fleet-epm-packages-bulk-uninstall - parameters: - - description: A required header to protect against CSRF attacks - in: header - name: kbn-xsrf - required: true - schema: - example: 'true' - type: string - requestBody: - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - force: - default: false - type: boolean - packages: - items: - additionalProperties: false - type: object - properties: - name: - type: string - version: - type: string - required: - - name - - version - minItems: 1 - type: array - required: - - packages - responses: - '200': - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - taskId: - type: string - required: - - taskId - '400': - content: - application/json: - schema: - additionalProperties: false - description: Generic Error - type: object - properties: - attributes: {} - error: - type: string - errorType: - type: string - message: - type: string - statusCode: - type: number - required: - - message - - attributes - summary: Bulk uninstall packages - tags: - - Elastic Package Manager (EPM) - /api/fleet/epm/packages/_bulk_uninstall/{taskId}: - get: - description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' - operationId: get-fleet-epm-packages-bulk-uninstall-taskid - parameters: - - in: path - name: taskId - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - error: - additionalProperties: false - type: object - properties: - message: - type: string - required: - - message - results: - items: - additionalProperties: false - type: object - properties: - error: - additionalProperties: false - type: object - properties: - message: - type: string - required: - - message - name: - type: string - success: - type: boolean - required: - - name - - success - type: array - status: - type: string - required: - - status - '400': - content: - application/json: - schema: - additionalProperties: false - description: Generic Error - type: object - properties: - attributes: {} - error: - type: string - errorType: - type: string - message: - type: string - statusCode: - type: number - required: - - message - - attributes - summary: Get Bulk uninstall packages details - tags: - - Elastic Package Manager (EPM) - /api/fleet/epm/packages/_bulk_upgrade: - post: - description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' - operationId: post-fleet-epm-packages-bulk-upgrade - parameters: - - description: A required header to protect against CSRF attacks - in: header - name: kbn-xsrf - required: true - schema: - example: 'true' - type: string - requestBody: - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - force: - default: false - type: boolean - packages: - items: - additionalProperties: false - type: object - properties: - name: - type: string - version: - type: string - required: - - name - minItems: 1 - type: array - prerelease: - type: boolean - upgrade_package_policies: - default: false - type: boolean - required: - - packages - responses: - '200': - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - taskId: - type: string - required: - - taskId - '400': - content: - application/json: - schema: - additionalProperties: false - description: Generic Error - type: object - properties: - attributes: {} - error: - type: string - errorType: - type: string - message: - type: string - statusCode: - type: number - required: - - message - - attributes - summary: Bulk upgrade packages - tags: - - Elastic Package Manager (EPM) - /api/fleet/epm/packages/_bulk_upgrade/{taskId}: - get: - description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' - operationId: get-fleet-epm-packages-bulk-upgrade-taskid - parameters: - - in: path - name: taskId - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - error: - additionalProperties: false - type: object - properties: - message: - type: string - required: - - message - results: - items: - additionalProperties: false - type: object - properties: - error: - additionalProperties: false - type: object - properties: - message: - type: string - required: - - message - name: - type: string - success: - type: boolean - required: - - name - - success - type: array - status: - type: string - required: - - status - '400': - content: - application/json: - schema: - additionalProperties: false - description: Generic Error - type: object - properties: - attributes: {} - error: - type: string - errorType: - type: string - message: - type: string - statusCode: - type: number - required: - - message - - attributes - summary: Get Bulk upgrade packages details - tags: - - Elastic Package Manager (EPM) /api/fleet/epm/packages/{pkgName}/{pkgVersion}: delete: description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index 12fcb93ddb645..fb17bcf3e6a65 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -29419,304 +29419,6 @@ paths: summary: Bulk install packages tags: - Elastic Package Manager (EPM) - /api/fleet/epm/packages/_bulk_uninstall: - post: - description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' - operationId: post-fleet-epm-packages-bulk-uninstall - parameters: - - description: A required header to protect against CSRF attacks - in: header - name: kbn-xsrf - required: true - schema: - example: 'true' - type: string - requestBody: - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - force: - default: false - type: boolean - packages: - items: - additionalProperties: false - type: object - properties: - name: - type: string - version: - type: string - required: - - name - - version - minItems: 1 - type: array - required: - - packages - responses: - '200': - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - taskId: - type: string - required: - - taskId - '400': - content: - application/json: - schema: - additionalProperties: false - description: Generic Error - type: object - properties: - attributes: {} - error: - type: string - errorType: - type: string - message: - type: string - statusCode: - type: number - required: - - message - - attributes - summary: Bulk uninstall packages - tags: - - Elastic Package Manager (EPM) - /api/fleet/epm/packages/_bulk_uninstall/{taskId}: - get: - description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' - operationId: get-fleet-epm-packages-bulk-uninstall-taskid - parameters: - - in: path - name: taskId - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - error: - additionalProperties: false - type: object - properties: - message: - type: string - required: - - message - results: - items: - additionalProperties: false - type: object - properties: - error: - additionalProperties: false - type: object - properties: - message: - type: string - required: - - message - name: - type: string - success: - type: boolean - required: - - name - - success - type: array - status: - type: string - required: - - status - '400': - content: - application/json: - schema: - additionalProperties: false - description: Generic Error - type: object - properties: - attributes: {} - error: - type: string - errorType: - type: string - message: - type: string - statusCode: - type: number - required: - - message - - attributes - summary: Get Bulk uninstall packages details - tags: - - Elastic Package Manager (EPM) - /api/fleet/epm/packages/_bulk_upgrade: - post: - description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' - operationId: post-fleet-epm-packages-bulk-upgrade - parameters: - - description: A required header to protect against CSRF attacks - in: header - name: kbn-xsrf - required: true - schema: - example: 'true' - type: string - requestBody: - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - force: - default: false - type: boolean - packages: - items: - additionalProperties: false - type: object - properties: - name: - type: string - version: - type: string - required: - - name - minItems: 1 - type: array - prerelease: - type: boolean - upgrade_package_policies: - default: false - type: boolean - required: - - packages - responses: - '200': - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - taskId: - type: string - required: - - taskId - '400': - content: - application/json: - schema: - additionalProperties: false - description: Generic Error - type: object - properties: - attributes: {} - error: - type: string - errorType: - type: string - message: - type: string - statusCode: - type: number - required: - - message - - attributes - summary: Bulk upgrade packages - tags: - - Elastic Package Manager (EPM) - /api/fleet/epm/packages/_bulk_upgrade/{taskId}: - get: - description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' - operationId: get-fleet-epm-packages-bulk-upgrade-taskid - parameters: - - in: path - name: taskId - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - additionalProperties: false - type: object - properties: - error: - additionalProperties: false - type: object - properties: - message: - type: string - required: - - message - results: - items: - additionalProperties: false - type: object - properties: - error: - additionalProperties: false - type: object - properties: - message: - type: string - required: - - message - name: - type: string - success: - type: boolean - required: - - name - - success - type: array - status: - type: string - required: - - status - '400': - content: - application/json: - schema: - additionalProperties: false - description: Generic Error - type: object - properties: - attributes: {} - error: - type: string - errorType: - type: string - message: - type: string - statusCode: - type: number - required: - - message - - attributes - summary: Get Bulk upgrade packages details - tags: - - Elastic Package Manager (EPM) /api/fleet/epm/packages/{pkgName}/{pkgVersion}: delete: description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' From f51ac4256c7b742dc7189ec3a08c443853d9bdcf Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Thu, 12 Jun 2025 11:58:58 +0200 Subject: [PATCH 11/24] Fix FTR tests --- .../fleet_api_integration/apis/agent_policy/agent_policy.ts | 5 +++++ .../fleet_api_integration/apis/epm/install_remove_assets.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts index db8d7bf0c1a4b..a32242442023c 100644 --- a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts +++ b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy.ts @@ -426,6 +426,7 @@ export default function (providerContext: FtrProviderContext) { package: { name: 'system', }, + latest_revision: true, }, }) ), @@ -464,6 +465,7 @@ export default function (providerContext: FtrProviderContext) { package: { name: 'system', }, + latest_revision: true, }, }); packagePoliciesToDeleteIds.push('package-policy-1'); @@ -476,6 +478,7 @@ export default function (providerContext: FtrProviderContext) { package: { name: 'system', }, + latest_revision: true, }, }); packagePoliciesToDeleteIds.push('package-policy-2'); @@ -880,6 +883,7 @@ export default function (providerContext: FtrProviderContext) { package: { name: 'system', }, + latest_revision: true, }, }), ]); @@ -964,6 +968,7 @@ export default function (providerContext: FtrProviderContext) { package: { name: 'system', }, + latest_revision: true, }, }), ]); diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts index 64fb4904023f5..376efd89db811 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts @@ -847,6 +847,7 @@ const expectAssetsInstalled = ({ install_format_schema_version: FLEET_INSTALL_FORMAT_VERSION, verification_status: 'unknown', verification_key_id: null, + latest_version: true, }); }); }; From 53a8b0efbeb8eae69f0eee1203f384cce07c49b9 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Fri, 13 Jun 2025 14:50:13 +0200 Subject: [PATCH 12/24] Fix more FTR tests --- .../ci_checks/saved_objects/check_registered_types.test.ts | 6 +++--- .../fleet_api_integration/apis/download_sources/crud.ts | 1 + .../fleet_api_integration/apis/fleet_server_hosts/crud.ts | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts index cae2af2f8b898..44a72791aae29 100644 --- a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts +++ b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts @@ -100,7 +100,7 @@ describe('checking migration metadata changes on all registered SO types', () => "entity-definition": "1c6bff35c423d5dc5650bc806cf2899e4706a0bc", "entity-discovery-api-key": "c267a65c69171d1804362155c1378365f5acef88", "entity-engine-status": "09f6a617020708e4f638137e5ef35bd9534133be", - "epm-packages": "a0b5685bb4644957d975421d9fd0d3b1b6a8c944", + "epm-packages": "5a9f55e38d424f5b5ebbfeac802788b5b05d867f", "epm-packages-assets": "7a3e58efd9a14191d0d1a00b8aaed30a145fd0b1", "event-annotation-group": "715ba867d8c68f3c9438052210ea1c30a9362582", "event_loop_delays_daily": "01b967e8e043801357503de09199dfa3853bab88", @@ -113,7 +113,7 @@ describe('checking migration metadata changes on all registered SO types', () => "fleet-agent-policies": "f69f7c5639f4cf9e85077c904e161f3574ac3ca2", "fleet-fleet-server-host": "232d98738d5321b86edc426e21a9ca2f607da999", "fleet-message-signing-keys": "93421f43fed2526b59092a4e3c65d64bc2266c0f", - "fleet-package-policies": "efd05a0ed95f387cecf0fad8902c482a5732668b", + "fleet-package-policies": "b1ded996118af658bc420a737ff3c4d784641fc7", "fleet-preconfiguration-deletion-record": "c52ea1e13c919afe8a5e8e3adbb7080980ecc08e", "fleet-proxy": "6cb688f0d2dd856400c1dbc998b28704ff70363d", "fleet-setup-lock": "0dc784792c79b5af5a6e6b5dcac06b0dbaa90bde", @@ -129,7 +129,7 @@ describe('checking migration metadata changes on all registered SO types', () => "ingest-agent-policies": "cfe66f4aeca8f53b26bd4ddb0e956de1637d774e", "ingest-download-sources": "5be99940d6b5f9121b2fd279708d14e2bc0bde26", "ingest-outputs": "6743521f501bd77b1523dbb1df48d7c47fdad529", - "ingest-package-policies": "cb7e5f23e0af62f2d66e194ad2b108c9645e422c", + "ingest-package-policies": "6a80000fdf2544f2485b0c6a51ecc434b6a12987", "ingest_manager_settings": "111a616eb72627c002029c19feb9e6c439a10505", "intercept_interaction_record": "13587751af378409df5cadd08aeb0d3884b1645a", "intercept_trigger_record": "9223039379bf9997781ad91df120eb360c3e6b77", diff --git a/x-pack/test/fleet_api_integration/apis/download_sources/crud.ts b/x-pack/test/fleet_api_integration/apis/download_sources/crud.ts index 09125977ef2f8..2641800c0c354 100644 --- a/x-pack/test/fleet_api_integration/apis/download_sources/crud.ts +++ b/x-pack/test/fleet_api_integration/apis/download_sources/crud.ts @@ -46,6 +46,7 @@ export default function (providerContext: FtrProviderContext) { package: { name: 'fleet_server', }, + latest_revision: true, }, }); }; diff --git a/x-pack/test/fleet_api_integration/apis/fleet_server_hosts/crud.ts b/x-pack/test/fleet_api_integration/apis/fleet_server_hosts/crud.ts index 33d0cd94126cf..0ce6b8623c230 100644 --- a/x-pack/test/fleet_api_integration/apis/fleet_server_hosts/crud.ts +++ b/x-pack/test/fleet_api_integration/apis/fleet_server_hosts/crud.ts @@ -76,6 +76,7 @@ export default function (providerContext: FtrProviderContext) { package: { name: 'fleet_server', }, + latest_revision: true, }, }); }; From 7cfea07ba40829394d80aff700449c42a2263c81 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Fri, 13 Jun 2025 16:21:52 +0200 Subject: [PATCH 13/24] Fix merge conflict mistake --- .../plugins/shared/fleet/common/experimental_features.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/platform/plugins/shared/fleet/common/experimental_features.ts b/x-pack/platform/plugins/shared/fleet/common/experimental_features.ts index da7edcffeecc6..0fb9344525713 100644 --- a/x-pack/platform/plugins/shared/fleet/common/experimental_features.ts +++ b/x-pack/platform/plugins/shared/fleet/common/experimental_features.ts @@ -13,8 +13,8 @@ const _allowedExperimentalValues = { enableAutomaticAgentUpgrades: true, enableSyncIntegrationsOnRemote: true, enableSSLSecrets: false, - installedIntegrationsTabularUI: false, - enabledUpgradeAgentlessDeploymentsTask: false, + installedIntegrationsTabularUI: true, + enabledUpgradeAgentlessDeploymentsTask: true, enablePackageRollback: false, }; From e97f25260ee9842c3d71062844f6f6616fc1070a Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 13 Jun 2025 14:46:51 +0000 Subject: [PATCH 14/24] [CI] Auto-commit changed files from 'node scripts/capture_oas_snapshot --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/streams --include-path /api/fleet --include-path /api/dashboards --include-path /api/saved_objects/_import --include-path /api/saved_objects/_export --include-path /api/maintenance_window --update' --- oas_docs/bundle.json | 454 ++++++++++++++++++++++++++++++++ oas_docs/bundle.serverless.json | 454 ++++++++++++++++++++++++++++++++ 2 files changed, 908 insertions(+) diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index d52f8257ea256..e7fb43de94def 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -26252,6 +26252,460 @@ ] } }, + "/api/fleet/epm/packages/_bulk_uninstall": { + "post": { + "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", + "operationId": "post-fleet-epm-packages-bulk-uninstall", + "parameters": [ + { + "description": "A required header to protect against CSRF attacks", + "in": "header", + "name": "kbn-xsrf", + "required": true, + "schema": { + "example": "true", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "force": { + "default": false, + "type": "boolean" + }, + "packages": { + "items": { + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ + "name", + "version" + ], + "type": "object" + }, + "minItems": 1, + "type": "array" + } + }, + "required": [ + "packages" + ], + "type": "object" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "taskId": { + "type": "string" + } + }, + "required": [ + "taskId" + ], + "type": "object" + } + } + } + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "description": "Generic Error", + "properties": { + "attributes": {}, + "error": { + "type": "string" + }, + "errorType": { + "type": "string" + }, + "message": { + "type": "string" + }, + "statusCode": { + "type": "number" + } + }, + "required": [ + "message", + "attributes" + ], + "type": "object" + } + } + } + } + }, + "summary": "Bulk uninstall packages", + "tags": [ + "Elastic Package Manager (EPM)" + ] + } + }, + "/api/fleet/epm/packages/_bulk_uninstall/{taskId}": { + "get": { + "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", + "operationId": "get-fleet-epm-packages-bulk-uninstall-taskid", + "parameters": [ + { + "in": "path", + "name": "taskId", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "error": { + "additionalProperties": false, + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "results": { + "items": { + "additionalProperties": false, + "properties": { + "error": { + "additionalProperties": false, + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "name": { + "type": "string" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "name", + "success" + ], + "type": "object" + }, + "type": "array" + }, + "status": { + "type": "string" + } + }, + "required": [ + "status" + ], + "type": "object" + } + } + } + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "description": "Generic Error", + "properties": { + "attributes": {}, + "error": { + "type": "string" + }, + "errorType": { + "type": "string" + }, + "message": { + "type": "string" + }, + "statusCode": { + "type": "number" + } + }, + "required": [ + "message", + "attributes" + ], + "type": "object" + } + } + } + } + }, + "summary": "Get Bulk uninstall packages details", + "tags": [ + "Elastic Package Manager (EPM)" + ] + } + }, + "/api/fleet/epm/packages/_bulk_upgrade": { + "post": { + "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", + "operationId": "post-fleet-epm-packages-bulk-upgrade", + "parameters": [ + { + "description": "A required header to protect against CSRF attacks", + "in": "header", + "name": "kbn-xsrf", + "required": true, + "schema": { + "example": "true", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "force": { + "default": false, + "type": "boolean" + }, + "packages": { + "items": { + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "minItems": 1, + "type": "array" + }, + "prerelease": { + "type": "boolean" + }, + "upgrade_package_policies": { + "default": false, + "type": "boolean" + } + }, + "required": [ + "packages" + ], + "type": "object" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "taskId": { + "type": "string" + } + }, + "required": [ + "taskId" + ], + "type": "object" + } + } + } + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "description": "Generic Error", + "properties": { + "attributes": {}, + "error": { + "type": "string" + }, + "errorType": { + "type": "string" + }, + "message": { + "type": "string" + }, + "statusCode": { + "type": "number" + } + }, + "required": [ + "message", + "attributes" + ], + "type": "object" + } + } + } + } + }, + "summary": "Bulk upgrade packages", + "tags": [ + "Elastic Package Manager (EPM)" + ] + } + }, + "/api/fleet/epm/packages/_bulk_upgrade/{taskId}": { + "get": { + "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", + "operationId": "get-fleet-epm-packages-bulk-upgrade-taskid", + "parameters": [ + { + "in": "path", + "name": "taskId", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "error": { + "additionalProperties": false, + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "results": { + "items": { + "additionalProperties": false, + "properties": { + "error": { + "additionalProperties": false, + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "name": { + "type": "string" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "name", + "success" + ], + "type": "object" + }, + "type": "array" + }, + "status": { + "type": "string" + } + }, + "required": [ + "status" + ], + "type": "object" + } + } + } + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "description": "Generic Error", + "properties": { + "attributes": {}, + "error": { + "type": "string" + }, + "errorType": { + "type": "string" + }, + "message": { + "type": "string" + }, + "statusCode": { + "type": "number" + } + }, + "required": [ + "message", + "attributes" + ], + "type": "object" + } + } + } + } + }, + "summary": "Get Bulk upgrade packages details", + "tags": [ + "Elastic Package Manager (EPM)" + ] + } + }, "/api/fleet/epm/packages/installed": { "get": { "description": "[Required authorization] Route required privileges: integrations-read OR fleet-setup OR fleet-all.", diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index ee7272819a72b..13cb962947708 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -26252,6 +26252,460 @@ ] } }, + "/api/fleet/epm/packages/_bulk_uninstall": { + "post": { + "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", + "operationId": "post-fleet-epm-packages-bulk-uninstall", + "parameters": [ + { + "description": "A required header to protect against CSRF attacks", + "in": "header", + "name": "kbn-xsrf", + "required": true, + "schema": { + "example": "true", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "force": { + "default": false, + "type": "boolean" + }, + "packages": { + "items": { + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ + "name", + "version" + ], + "type": "object" + }, + "minItems": 1, + "type": "array" + } + }, + "required": [ + "packages" + ], + "type": "object" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "taskId": { + "type": "string" + } + }, + "required": [ + "taskId" + ], + "type": "object" + } + } + } + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "description": "Generic Error", + "properties": { + "attributes": {}, + "error": { + "type": "string" + }, + "errorType": { + "type": "string" + }, + "message": { + "type": "string" + }, + "statusCode": { + "type": "number" + } + }, + "required": [ + "message", + "attributes" + ], + "type": "object" + } + } + } + } + }, + "summary": "Bulk uninstall packages", + "tags": [ + "Elastic Package Manager (EPM)" + ] + } + }, + "/api/fleet/epm/packages/_bulk_uninstall/{taskId}": { + "get": { + "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", + "operationId": "get-fleet-epm-packages-bulk-uninstall-taskid", + "parameters": [ + { + "in": "path", + "name": "taskId", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "error": { + "additionalProperties": false, + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "results": { + "items": { + "additionalProperties": false, + "properties": { + "error": { + "additionalProperties": false, + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "name": { + "type": "string" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "name", + "success" + ], + "type": "object" + }, + "type": "array" + }, + "status": { + "type": "string" + } + }, + "required": [ + "status" + ], + "type": "object" + } + } + } + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "description": "Generic Error", + "properties": { + "attributes": {}, + "error": { + "type": "string" + }, + "errorType": { + "type": "string" + }, + "message": { + "type": "string" + }, + "statusCode": { + "type": "number" + } + }, + "required": [ + "message", + "attributes" + ], + "type": "object" + } + } + } + } + }, + "summary": "Get Bulk uninstall packages details", + "tags": [ + "Elastic Package Manager (EPM)" + ] + } + }, + "/api/fleet/epm/packages/_bulk_upgrade": { + "post": { + "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", + "operationId": "post-fleet-epm-packages-bulk-upgrade", + "parameters": [ + { + "description": "A required header to protect against CSRF attacks", + "in": "header", + "name": "kbn-xsrf", + "required": true, + "schema": { + "example": "true", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "force": { + "default": false, + "type": "boolean" + }, + "packages": { + "items": { + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "minItems": 1, + "type": "array" + }, + "prerelease": { + "type": "boolean" + }, + "upgrade_package_policies": { + "default": false, + "type": "boolean" + } + }, + "required": [ + "packages" + ], + "type": "object" + } + } + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "taskId": { + "type": "string" + } + }, + "required": [ + "taskId" + ], + "type": "object" + } + } + } + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "description": "Generic Error", + "properties": { + "attributes": {}, + "error": { + "type": "string" + }, + "errorType": { + "type": "string" + }, + "message": { + "type": "string" + }, + "statusCode": { + "type": "number" + } + }, + "required": [ + "message", + "attributes" + ], + "type": "object" + } + } + } + } + }, + "summary": "Bulk upgrade packages", + "tags": [ + "Elastic Package Manager (EPM)" + ] + } + }, + "/api/fleet/epm/packages/_bulk_upgrade/{taskId}": { + "get": { + "description": "[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.", + "operationId": "get-fleet-epm-packages-bulk-upgrade-taskid", + "parameters": [ + { + "in": "path", + "name": "taskId", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "properties": { + "error": { + "additionalProperties": false, + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "results": { + "items": { + "additionalProperties": false, + "properties": { + "error": { + "additionalProperties": false, + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + }, + "name": { + "type": "string" + }, + "success": { + "type": "boolean" + } + }, + "required": [ + "name", + "success" + ], + "type": "object" + }, + "type": "array" + }, + "status": { + "type": "string" + } + }, + "required": [ + "status" + ], + "type": "object" + } + } + } + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": false, + "description": "Generic Error", + "properties": { + "attributes": {}, + "error": { + "type": "string" + }, + "errorType": { + "type": "string" + }, + "message": { + "type": "string" + }, + "statusCode": { + "type": "number" + } + }, + "required": [ + "message", + "attributes" + ], + "type": "object" + } + } + } + } + }, + "summary": "Get Bulk upgrade packages details", + "tags": [ + "Elastic Package Manager (EPM)" + ] + } + }, "/api/fleet/epm/packages/installed": { "get": { "description": "[Required authorization] Route required privileges: integrations-read OR fleet-setup OR fleet-all.", From 6e422a6cef42e4b1492ed4e50b6d2e52adcb2418 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 13 Jun 2025 14:48:11 +0000 Subject: [PATCH 15/24] [CI] Auto-commit changed files from 'node scripts/jest_integration -u src/core/server/integration_tests/ci_checks' --- .../ci_checks/saved_objects/check_registered_types.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts index 44a72791aae29..cae2af2f8b898 100644 --- a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts +++ b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts @@ -100,7 +100,7 @@ describe('checking migration metadata changes on all registered SO types', () => "entity-definition": "1c6bff35c423d5dc5650bc806cf2899e4706a0bc", "entity-discovery-api-key": "c267a65c69171d1804362155c1378365f5acef88", "entity-engine-status": "09f6a617020708e4f638137e5ef35bd9534133be", - "epm-packages": "5a9f55e38d424f5b5ebbfeac802788b5b05d867f", + "epm-packages": "a0b5685bb4644957d975421d9fd0d3b1b6a8c944", "epm-packages-assets": "7a3e58efd9a14191d0d1a00b8aaed30a145fd0b1", "event-annotation-group": "715ba867d8c68f3c9438052210ea1c30a9362582", "event_loop_delays_daily": "01b967e8e043801357503de09199dfa3853bab88", @@ -113,7 +113,7 @@ describe('checking migration metadata changes on all registered SO types', () => "fleet-agent-policies": "f69f7c5639f4cf9e85077c904e161f3574ac3ca2", "fleet-fleet-server-host": "232d98738d5321b86edc426e21a9ca2f607da999", "fleet-message-signing-keys": "93421f43fed2526b59092a4e3c65d64bc2266c0f", - "fleet-package-policies": "b1ded996118af658bc420a737ff3c4d784641fc7", + "fleet-package-policies": "efd05a0ed95f387cecf0fad8902c482a5732668b", "fleet-preconfiguration-deletion-record": "c52ea1e13c919afe8a5e8e3adbb7080980ecc08e", "fleet-proxy": "6cb688f0d2dd856400c1dbc998b28704ff70363d", "fleet-setup-lock": "0dc784792c79b5af5a6e6b5dcac06b0dbaa90bde", @@ -129,7 +129,7 @@ describe('checking migration metadata changes on all registered SO types', () => "ingest-agent-policies": "cfe66f4aeca8f53b26bd4ddb0e956de1637d774e", "ingest-download-sources": "5be99940d6b5f9121b2fd279708d14e2bc0bde26", "ingest-outputs": "6743521f501bd77b1523dbb1df48d7c47fdad529", - "ingest-package-policies": "6a80000fdf2544f2485b0c6a51ecc434b6a12987", + "ingest-package-policies": "cb7e5f23e0af62f2d66e194ad2b108c9645e422c", "ingest_manager_settings": "111a616eb72627c002029c19feb9e6c439a10505", "intercept_interaction_record": "13587751af378409df5cadd08aeb0d3884b1645a", "intercept_trigger_record": "9223039379bf9997781ad91df120eb360c3e6b77", From cd087381afa656ecd3626ddabaaa402cafb4d794 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Mon, 16 Jun 2025 14:58:42 +0200 Subject: [PATCH 16/24] Save previous version in package SO on update --- .../current_fields.json | 2 +- .../current_mappings.json | 6 +- .../shared/fleet/common/types/models/epm.ts | 2 +- .../fleet/server/saved_objects/index.ts | 10 ++-- ...stallation_latest_version_backfill.test.ts | 59 ------------------- .../installation_latest_version_backfill.ts | 21 ------- .../fleet/server/services/epm/packages/get.ts | 1 - .../server/services/epm/packages/install.ts | 40 ++----------- 8 files changed, 15 insertions(+), 126 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.test.ts delete mode 100644 x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.ts diff --git a/packages/kbn-check-mappings-update-cli/current_fields.json b/packages/kbn-check-mappings-update-cli/current_fields.json index 31e3df6042cd5..fd47a8d7a05ac 100644 --- a/packages/kbn-check-mappings-update-cli/current_fields.json +++ b/packages/kbn-check-mappings-update-cli/current_fields.json @@ -368,9 +368,9 @@ "keep_policies_up_to_date", "latest_executed_state", "latest_install_failed_attempts", - "latest_version", "name", "package_assets", + "previous_version", "verification_key_id", "verification_status", "version" diff --git a/packages/kbn-check-mappings-update-cli/current_mappings.json b/packages/kbn-check-mappings-update-cli/current_mappings.json index 15d168e076d2b..bb9933af1668c 100644 --- a/packages/kbn-check-mappings-update-cli/current_mappings.json +++ b/packages/kbn-check-mappings-update-cli/current_mappings.json @@ -1249,9 +1249,6 @@ "enabled": false, "type": "object" }, - "latest_version": { - "type": "boolean" - }, "name": { "type": "keyword" }, @@ -1259,6 +1256,9 @@ "dynamic": false, "properties": {} }, + "previous_version": { + "type": "keyword" + }, "verification_key_id": { "type": "keyword" }, diff --git a/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts b/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts index ec2c0db85d44c..ef81f2adcdf88 100644 --- a/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts +++ b/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts @@ -684,7 +684,7 @@ export interface Installation { latest_uninstall_failed_attempts?: FailedAttempt[]; latest_executed_state?: InstallLatestExecutedState; latest_custom_asset_install_failed_attempts?: { [asset: string]: CustomAssetFailedAttempt }; - latest_version?: boolean; + previous_version?: string; } export interface PackageUsageStats { diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts index 6ec847d688fbe..e4ff0e805cdd7 100644 --- a/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts +++ b/x-pack/platform/plugins/shared/fleet/server/saved_objects/index.ts @@ -1074,7 +1074,7 @@ export const getSavedObjectTypes = ( }, }, }, - latest_version: { type: 'boolean' }, + previous_version: { type: 'keyword' }, }, }, modelVersions: { @@ -1112,9 +1112,7 @@ export const getSavedObjectTypes = ( changes: [ { type: 'mappings_addition', - addedMappings: { - latest_version: { type: 'boolean' }, - }, + addedMappings: {}, // Empty to add dynamic:false }, ], }, @@ -1122,7 +1120,9 @@ export const getSavedObjectTypes = ( changes: [ { type: 'mappings_addition', - addedMappings: {}, // Empty to add dynamic:false + addedMappings: { + previous_version: { type: 'keyword' }, + }, }, ], }, diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.test.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.test.ts deleted file mode 100644 index 862f410e5ab0c..0000000000000 --- a/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { - SavedObject, - SavedObjectModelTransformationContext, -} from '@kbn/core-saved-objects-server'; - -import type { Installation } from '../../../common'; - -import { backfillInstallationLatestVersion } from './installation_latest_version_backfill'; - -describe('backfillInstallationLatestVersion', () => { - const doc: SavedObject = { - id: 'my-package', - type: 'epm-packages', - references: [], - attributes: { - installed_kibana: [], - installed_es: [], - name: 'my-package', - version: '1.0.0', - install_status: 'installed', - install_version: '1.0.0', - install_started_at: '2023-10-01T00:00:00.000Z', - install_source: 'registry', - es_index_patterns: {}, - verification_status: 'verified', - }, - }; - - it('should set latest_revision to true if not defined', () => { - const migratedDoc = backfillInstallationLatestVersion( - doc, - {} as SavedObjectModelTransformationContext - ); - - expect(migratedDoc.attributes.latest_version).toBe(true); - }); - - it('should not change latest_revision if already defined', () => { - const migratedDoc = backfillInstallationLatestVersion( - { - ...doc, - attributes: { - ...doc.attributes, - latest_version: false, - }, - }, - {} as SavedObjectModelTransformationContext - ); - - expect(migratedDoc.attributes.latest_version).toBe(false); - }); -}); diff --git a/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.ts b/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.ts deleted file mode 100644 index b0244227f1147..0000000000000 --- a/x-pack/platform/plugins/shared/fleet/server/saved_objects/model_versions/installation_latest_version_backfill.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { SavedObjectModelDataBackfillFn } from '@kbn/core-saved-objects-server'; - -import type { Installation } from '../../../common'; - -export const backfillInstallationLatestVersion: SavedObjectModelDataBackfillFn< - Installation, - Installation -> = (doc) => { - if (doc.attributes.latest_version === undefined) { - doc.attributes.latest_version = true; - } - - return doc; -}; diff --git a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/get.ts b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/get.ts index 75fbce7564e07..f7cbc87b8ca2c 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/get.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/get.ts @@ -308,7 +308,6 @@ export async function getPackageSavedObjects( ...(options || {}), type: PACKAGES_SAVED_OBJECT_TYPE, perPage: SO_SEARCH_LIMIT, - filter: `${PACKAGES_SAVED_OBJECT_TYPE}.attributes.latest_version: true`, }); for (const savedObject of result.saved_objects) { diff --git a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts index db3c069986d20..49d0dd473fecb 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts @@ -1114,11 +1114,16 @@ export async function restartInstallation(options: { }) { const { savedObjectsClient, pkgVersion, pkgName, installSource, verificationResult } = options; + const currentInstallation = await savedObjectsClient.get( + PACKAGES_SAVED_OBJECT_TYPE, + pkgName + ); let savedObjectUpdate: Partial = { install_version: pkgVersion, install_status: 'installing', install_started_at: new Date().toISOString(), install_source: installSource, + previous_version: currentInstallation.attributes.version, }; if (verificationResult) { @@ -1136,40 +1141,6 @@ export async function restartInstallation(options: { savedObjectType: PACKAGES_SAVED_OBJECT_TYPE, }); - if (appContextService.getExperimentalFeatures().enablePackageRollback) { - const currentInstallation = await savedObjectsClient.get( - PACKAGES_SAVED_OBJECT_TYPE, - pkgName - ); - const previousVersionSO = { - ...currentInstallation, - id: `${pkgName}:prev`, - attributes: { - ...currentInstallation.attributes, - latest_version: false, - }, - }; - try { - await savedObjectsClient.update( - PACKAGES_SAVED_OBJECT_TYPE, - `${pkgName}:prev`, - previousVersionSO.attributes - ); - } catch (e) { - if (e.output.statusCode === 404) { - await savedObjectsClient.create( - PACKAGES_SAVED_OBJECT_TYPE, - previousVersionSO.attributes, - { - id: `${pkgName}:prev`, - } - ); - } else { - throw e; - } - } - } - await savedObjectsClient.update(PACKAGES_SAVED_OBJECT_TYPE, pkgName, savedObjectUpdate); } @@ -1210,7 +1181,6 @@ export async function createInstallation(options: { install_format_schema_version: FLEET_INSTALL_FORMAT_VERSION, keep_policies_up_to_date: defaultKeepPoliciesUpToDate, verification_status: 'unknown', - latest_version: true, }; if (verificationResult) { From 079ff4972a5420b1c057a48ac3799514e4b20ec8 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Mon, 16 Jun 2025 15:20:17 +0200 Subject: [PATCH 17/24] Fix --- .../test/fleet_api_integration/apis/epm/install_remove_assets.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts index 376efd89db811..64fb4904023f5 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts @@ -847,7 +847,6 @@ const expectAssetsInstalled = ({ install_format_schema_version: FLEET_INSTALL_FORMAT_VERSION, verification_status: 'unknown', verification_key_id: null, - latest_version: true, }); }); }; From f2a3dfd4bacd334c95eadc76319edbb538b8d636 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:37:29 +0000 Subject: [PATCH 18/24] [CI] Auto-commit changed files from 'make api-docs' --- oas_docs/output/kibana.serverless.yaml | 298 +++++++++++++++++++++++++ oas_docs/output/kibana.yaml | 298 +++++++++++++++++++++++++ 2 files changed, 596 insertions(+) diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index 4bb4be16b9366..d99830440d591 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -27177,6 +27177,304 @@ paths: summary: Bulk install packages tags: - Elastic Package Manager (EPM) + /api/fleet/epm/packages/_bulk_uninstall: + post: + description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' + operationId: post-fleet-epm-packages-bulk-uninstall + parameters: + - description: A required header to protect against CSRF attacks + in: header + name: kbn-xsrf + required: true + schema: + example: 'true' + type: string + requestBody: + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + force: + default: false + type: boolean + packages: + items: + additionalProperties: false + type: object + properties: + name: + type: string + version: + type: string + required: + - name + - version + minItems: 1 + type: array + required: + - packages + responses: + '200': + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + taskId: + type: string + required: + - taskId + '400': + content: + application/json: + schema: + additionalProperties: false + description: Generic Error + type: object + properties: + attributes: {} + error: + type: string + errorType: + type: string + message: + type: string + statusCode: + type: number + required: + - message + - attributes + summary: Bulk uninstall packages + tags: + - Elastic Package Manager (EPM) + /api/fleet/epm/packages/_bulk_uninstall/{taskId}: + get: + description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' + operationId: get-fleet-epm-packages-bulk-uninstall-taskid + parameters: + - in: path + name: taskId + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + error: + additionalProperties: false + type: object + properties: + message: + type: string + required: + - message + results: + items: + additionalProperties: false + type: object + properties: + error: + additionalProperties: false + type: object + properties: + message: + type: string + required: + - message + name: + type: string + success: + type: boolean + required: + - name + - success + type: array + status: + type: string + required: + - status + '400': + content: + application/json: + schema: + additionalProperties: false + description: Generic Error + type: object + properties: + attributes: {} + error: + type: string + errorType: + type: string + message: + type: string + statusCode: + type: number + required: + - message + - attributes + summary: Get Bulk uninstall packages details + tags: + - Elastic Package Manager (EPM) + /api/fleet/epm/packages/_bulk_upgrade: + post: + description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' + operationId: post-fleet-epm-packages-bulk-upgrade + parameters: + - description: A required header to protect against CSRF attacks + in: header + name: kbn-xsrf + required: true + schema: + example: 'true' + type: string + requestBody: + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + force: + default: false + type: boolean + packages: + items: + additionalProperties: false + type: object + properties: + name: + type: string + version: + type: string + required: + - name + minItems: 1 + type: array + prerelease: + type: boolean + upgrade_package_policies: + default: false + type: boolean + required: + - packages + responses: + '200': + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + taskId: + type: string + required: + - taskId + '400': + content: + application/json: + schema: + additionalProperties: false + description: Generic Error + type: object + properties: + attributes: {} + error: + type: string + errorType: + type: string + message: + type: string + statusCode: + type: number + required: + - message + - attributes + summary: Bulk upgrade packages + tags: + - Elastic Package Manager (EPM) + /api/fleet/epm/packages/_bulk_upgrade/{taskId}: + get: + description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' + operationId: get-fleet-epm-packages-bulk-upgrade-taskid + parameters: + - in: path + name: taskId + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + error: + additionalProperties: false + type: object + properties: + message: + type: string + required: + - message + results: + items: + additionalProperties: false + type: object + properties: + error: + additionalProperties: false + type: object + properties: + message: + type: string + required: + - message + name: + type: string + success: + type: boolean + required: + - name + - success + type: array + status: + type: string + required: + - status + '400': + content: + application/json: + schema: + additionalProperties: false + description: Generic Error + type: object + properties: + attributes: {} + error: + type: string + errorType: + type: string + message: + type: string + statusCode: + type: number + required: + - message + - attributes + summary: Get Bulk upgrade packages details + tags: + - Elastic Package Manager (EPM) /api/fleet/epm/packages/{pkgName}/{pkgVersion}: delete: description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index fb17bcf3e6a65..12fcb93ddb645 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -29419,6 +29419,304 @@ paths: summary: Bulk install packages tags: - Elastic Package Manager (EPM) + /api/fleet/epm/packages/_bulk_uninstall: + post: + description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' + operationId: post-fleet-epm-packages-bulk-uninstall + parameters: + - description: A required header to protect against CSRF attacks + in: header + name: kbn-xsrf + required: true + schema: + example: 'true' + type: string + requestBody: + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + force: + default: false + type: boolean + packages: + items: + additionalProperties: false + type: object + properties: + name: + type: string + version: + type: string + required: + - name + - version + minItems: 1 + type: array + required: + - packages + responses: + '200': + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + taskId: + type: string + required: + - taskId + '400': + content: + application/json: + schema: + additionalProperties: false + description: Generic Error + type: object + properties: + attributes: {} + error: + type: string + errorType: + type: string + message: + type: string + statusCode: + type: number + required: + - message + - attributes + summary: Bulk uninstall packages + tags: + - Elastic Package Manager (EPM) + /api/fleet/epm/packages/_bulk_uninstall/{taskId}: + get: + description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' + operationId: get-fleet-epm-packages-bulk-uninstall-taskid + parameters: + - in: path + name: taskId + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + error: + additionalProperties: false + type: object + properties: + message: + type: string + required: + - message + results: + items: + additionalProperties: false + type: object + properties: + error: + additionalProperties: false + type: object + properties: + message: + type: string + required: + - message + name: + type: string + success: + type: boolean + required: + - name + - success + type: array + status: + type: string + required: + - status + '400': + content: + application/json: + schema: + additionalProperties: false + description: Generic Error + type: object + properties: + attributes: {} + error: + type: string + errorType: + type: string + message: + type: string + statusCode: + type: number + required: + - message + - attributes + summary: Get Bulk uninstall packages details + tags: + - Elastic Package Manager (EPM) + /api/fleet/epm/packages/_bulk_upgrade: + post: + description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' + operationId: post-fleet-epm-packages-bulk-upgrade + parameters: + - description: A required header to protect against CSRF attacks + in: header + name: kbn-xsrf + required: true + schema: + example: 'true' + type: string + requestBody: + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + force: + default: false + type: boolean + packages: + items: + additionalProperties: false + type: object + properties: + name: + type: string + version: + type: string + required: + - name + minItems: 1 + type: array + prerelease: + type: boolean + upgrade_package_policies: + default: false + type: boolean + required: + - packages + responses: + '200': + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + taskId: + type: string + required: + - taskId + '400': + content: + application/json: + schema: + additionalProperties: false + description: Generic Error + type: object + properties: + attributes: {} + error: + type: string + errorType: + type: string + message: + type: string + statusCode: + type: number + required: + - message + - attributes + summary: Bulk upgrade packages + tags: + - Elastic Package Manager (EPM) + /api/fleet/epm/packages/_bulk_upgrade/{taskId}: + get: + description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' + operationId: get-fleet-epm-packages-bulk-upgrade-taskid + parameters: + - in: path + name: taskId + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + additionalProperties: false + type: object + properties: + error: + additionalProperties: false + type: object + properties: + message: + type: string + required: + - message + results: + items: + additionalProperties: false + type: object + properties: + error: + additionalProperties: false + type: object + properties: + message: + type: string + required: + - message + name: + type: string + success: + type: boolean + required: + - name + - success + type: array + status: + type: string + required: + - status + '400': + content: + application/json: + schema: + additionalProperties: false + description: Generic Error + type: object + properties: + attributes: {} + error: + type: string + errorType: + type: string + message: + type: string + statusCode: + type: number + required: + - message + - attributes + summary: Get Bulk upgrade packages details + tags: + - Elastic Package Manager (EPM) /api/fleet/epm/packages/{pkgName}/{pkgVersion}: delete: description: '[Required authorization] Route required privileges: integrations-all AND fleet-agent-policies-all.' From 4e9cad6fcae1e7fb9974ad73d7827ace289c618c Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:40:59 +0000 Subject: [PATCH 19/24] [CI] Auto-commit changed files from 'node scripts/jest_integration -u src/core/server/integration_tests/ci_checks' --- .../ci_checks/saved_objects/check_registered_types.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts index cae2af2f8b898..22eb516be3176 100644 --- a/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts +++ b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts @@ -100,7 +100,7 @@ describe('checking migration metadata changes on all registered SO types', () => "entity-definition": "1c6bff35c423d5dc5650bc806cf2899e4706a0bc", "entity-discovery-api-key": "c267a65c69171d1804362155c1378365f5acef88", "entity-engine-status": "09f6a617020708e4f638137e5ef35bd9534133be", - "epm-packages": "a0b5685bb4644957d975421d9fd0d3b1b6a8c944", + "epm-packages": "db1a500677ffca84c2900df498f83626554cb4fb", "epm-packages-assets": "7a3e58efd9a14191d0d1a00b8aaed30a145fd0b1", "event-annotation-group": "715ba867d8c68f3c9438052210ea1c30a9362582", "event_loop_delays_daily": "01b967e8e043801357503de09199dfa3853bab88", From 3eb4c3e55db82ef483294efc4a648fc4be1d42f9 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Tue, 17 Jun 2025 14:30:57 +0200 Subject: [PATCH 20/24] Fix --- .../server/services/epm/packages/install.ts | 19 +++++++++++++------ .../steps/step_create_restart_installation.ts | 7 +++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts index 49d0dd473fecb..fb97f34eaaa42 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install.ts @@ -1111,19 +1111,22 @@ export async function restartInstallation(options: { pkgVersion: string; installSource: InstallSource; verificationResult?: PackageVerificationResult; + previousVersion?: string; }) { - const { savedObjectsClient, pkgVersion, pkgName, installSource, verificationResult } = options; + const { + savedObjectsClient, + pkgVersion, + pkgName, + installSource, + verificationResult, + previousVersion, + } = options; - const currentInstallation = await savedObjectsClient.get( - PACKAGES_SAVED_OBJECT_TYPE, - pkgName - ); let savedObjectUpdate: Partial = { install_version: pkgVersion, install_status: 'installing', install_started_at: new Date().toISOString(), install_source: installSource, - previous_version: currentInstallation.attributes.version, }; if (verificationResult) { @@ -1134,6 +1137,10 @@ export async function restartInstallation(options: { }; } + if (previousVersion) { + savedObjectUpdate.previous_version = previousVersion; + } + auditLoggingService.writeCustomSoAuditLog({ action: 'update', id: pkgName, diff --git a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install_state_machine/steps/step_create_restart_installation.ts b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install_state_machine/steps/step_create_restart_installation.ts index af0fb0fea9caf..8299a055aca21 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install_state_machine/steps/step_create_restart_installation.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/epm/packages/install_state_machine/steps/step_create_restart_installation.ts @@ -5,6 +5,8 @@ * 2.0. */ +import semverGt from 'semver/functions/gt'; + import { ConcurrentInstallOperationError } from '../../../../../errors'; import { MAX_TIME_COMPLETE_INSTALL } from '../../../../../constants'; @@ -29,6 +31,9 @@ export async function stepCreateRestartInstallation(context: InstallContext) { // if some installation already exists if (installedPkg) { + const previousVersion = semverGt(pkgVersion, installedPkg.attributes.install_version) + ? installedPkg.attributes.install_version + : undefined; const isStatusInstalling = installedPkg.attributes.install_status === 'installing'; const hasExceededTimeout = Date.now() - Date.parse(installedPkg.attributes.install_started_at) < @@ -50,6 +55,7 @@ export async function stepCreateRestartInstallation(context: InstallContext) { pkgVersion, installSource, verificationResult, + previousVersion, }) ); } else { @@ -72,6 +78,7 @@ export async function stepCreateRestartInstallation(context: InstallContext) { pkgVersion, installSource, verificationResult, + previousVersion, }) ); } From 2796dfde017c27b990ced4988b07da04b6d20ca1 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Tue, 17 Jun 2025 17:14:44 +0200 Subject: [PATCH 21/24] Fix remaining test failures --- .../server/integration_tests/fleet_usage_telemetry.test.ts | 2 ++ x-pack/test/fleet_api_integration/apis/epm/update_assets.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/x-pack/platform/plugins/shared/fleet/server/integration_tests/fleet_usage_telemetry.test.ts b/x-pack/platform/plugins/shared/fleet/server/integration_tests/fleet_usage_telemetry.test.ts index 4ececa60a4531..6ce4763a3ca12 100644 --- a/x-pack/platform/plugins/shared/fleet/server/integration_tests/fleet_usage_telemetry.test.ts +++ b/x-pack/platform/plugins/shared/fleet/server/integration_tests/fleet_usage_telemetry.test.ts @@ -367,6 +367,7 @@ describe('fleet usage telemetry', () => { }, }, ], + latest_revision: true, }); await soClient.create('ingest-package-policies', { @@ -381,6 +382,7 @@ describe('fleet usage telemetry', () => { policy_id: 'policy2', policy_ids: ['policy2', 'policy3'], inputs: [], + latest_revision: true, }); await soClient.create( diff --git a/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts b/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts index 8e248101a0cbb..d22e605880b31 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts @@ -622,6 +622,7 @@ export default function (providerContext: FtrProviderContext) { latest_install_failed_attempts: [], verification_status: 'unknown', verification_key_id: null, + previous_version: '0.1.0', }); }); }); From 78b2eede43908cac3cfd5d7d7b121901c62fe856 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Wed, 18 Jun 2025 10:55:21 +0200 Subject: [PATCH 22/24] Add check for bulk creating/updating previous revisions --- .../shared/fleet/server/services/package_policy.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts index 7c6645b0fec5b..6114eab2c7404 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts @@ -1657,20 +1657,24 @@ class PackagePolicyClientImpl implements PackagePolicyClient { // Store previous revision. if (appContextService.getExperimentalFeatures().enablePackageRollback) { - await soClient + if (previousPolicyRevisionsToCreate.length > 0) { + await soClient .bulkCreate(previousPolicyRevisionsToCreate) .catch( catchAndSetErrorStackTrace.withMessage( 'Saved objects bulk create of previous package policy revisions failed' ) ); - await soClient + } + if (previousPolicyRevisionsToUpdate.length > 0) { + await soClient .bulkUpdate(previousPolicyRevisionsToUpdate) .catch( catchAndSetErrorStackTrace.withMessage( 'Saved objects bulk update of previous package policy revisions failed' ) ); + } } // Update package policies SO. From 77b5bae36e11745e6dbe4ae90563dbcf55a6f9a1 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 18 Jun 2025 09:19:29 +0000 Subject: [PATCH 23/24] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../fleet/server/services/package_policy.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts index 6114eab2c7404..6e3e8af68157d 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/package_policy.ts @@ -1659,21 +1659,21 @@ class PackagePolicyClientImpl implements PackagePolicyClient { if (appContextService.getExperimentalFeatures().enablePackageRollback) { if (previousPolicyRevisionsToCreate.length > 0) { await soClient - .bulkCreate(previousPolicyRevisionsToCreate) - .catch( - catchAndSetErrorStackTrace.withMessage( - 'Saved objects bulk create of previous package policy revisions failed' - ) - ); + .bulkCreate(previousPolicyRevisionsToCreate) + .catch( + catchAndSetErrorStackTrace.withMessage( + 'Saved objects bulk create of previous package policy revisions failed' + ) + ); } if (previousPolicyRevisionsToUpdate.length > 0) { await soClient - .bulkUpdate(previousPolicyRevisionsToUpdate) - .catch( - catchAndSetErrorStackTrace.withMessage( - 'Saved objects bulk update of previous package policy revisions failed' - ) - ); + .bulkUpdate(previousPolicyRevisionsToUpdate) + .catch( + catchAndSetErrorStackTrace.withMessage( + 'Saved objects bulk update of previous package policy revisions failed' + ) + ); } } From 773a99526afd243c23f693e723f124e8a7ec21c4 Mon Sep 17 00:00:00 2001 From: jillguyonnet Date: Thu, 19 Jun 2025 17:10:58 +0200 Subject: [PATCH 24/24] Remove mapping definition of monitoring-entity-source --- packages/kbn-check-mappings-update-cli/current_fields.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/kbn-check-mappings-update-cli/current_fields.json b/packages/kbn-check-mappings-update-cli/current_fields.json index 6580ae70a3ce7..457cdcc2ec0ac 100644 --- a/packages/kbn-check-mappings-update-cli/current_fields.json +++ b/packages/kbn-check-mappings-update-cli/current_fields.json @@ -841,7 +841,6 @@ "job.job_id", "model_id" ], - "monitoring-entity-source": [], "monitoring-telemetry": [ "reportedClusterUuids" ],