diff --git a/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts index 718aca89ea4fd..4e4653ec023ce 100644 --- a/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts @@ -135,6 +135,7 @@ export const createAgentConfigHandler: RequestHandler< newSysPackageConfig.namespace = agentConfig.namespace; await packageConfigService.create(soClient, callCluster, newSysPackageConfig, { user, + bumpConfigRevision: false, }); } diff --git a/x-pack/plugins/ingest_manager/server/services/agent_config.ts b/x-pack/plugins/ingest_manager/server/services/agent_config.ts index c068b594318c1..0a9adc1f1c593 100644 --- a/x-pack/plugins/ingest_manager/server/services/agent_config.ts +++ b/x-pack/plugins/ingest_manager/server/services/agent_config.ts @@ -41,7 +41,8 @@ class AgentConfigService { soClient: SavedObjectsClientContract, id: string, agentConfig: Partial, - user?: AuthenticatedUser + user?: AuthenticatedUser, + options: { bumpRevision: boolean } = { bumpRevision: true } ): Promise { const oldAgentConfig = await this.get(soClient, id, false); @@ -60,7 +61,7 @@ class AgentConfigService { await soClient.update(SAVED_OBJECT_TYPE, id, { ...agentConfig, - revision: oldAgentConfig.revision + 1, + ...(options.bumpRevision ? { revision: oldAgentConfig.revision + 1 } : {}), updated_at: new Date().toISOString(), updated_by: user ? user.username : 'system', }); @@ -265,7 +266,7 @@ class AgentConfigService { soClient: SavedObjectsClientContract, id: string, packageConfigIds: string[], - options?: { user?: AuthenticatedUser } + options: { user?: AuthenticatedUser; bumpRevision: boolean } = { bumpRevision: true } ): Promise { const oldAgentConfig = await this.get(soClient, id, false); @@ -281,7 +282,8 @@ class AgentConfigService { [...((oldAgentConfig.package_configs || []) as string[])].concat(packageConfigIds) ), }, - options?.user + options?.user, + { bumpRevision: options.bumpRevision } ); } diff --git a/x-pack/plugins/ingest_manager/server/services/package_config.ts b/x-pack/plugins/ingest_manager/server/services/package_config.ts index e8ca09a83c2b6..c2d465cf7c73f 100644 --- a/x-pack/plugins/ingest_manager/server/services/package_config.ts +++ b/x-pack/plugins/ingest_manager/server/services/package_config.ts @@ -42,7 +42,7 @@ class PackageConfigService { soClient: SavedObjectsClientContract, callCluster: CallESAsCurrentUser, packageConfig: NewPackageConfig, - options?: { id?: string; user?: AuthenticatedUser } + options?: { id?: string; user?: AuthenticatedUser; bumpConfigRevision?: boolean } ): Promise { // Check that its agent config does not have a package config with the same name const parentAgentConfig = await agentConfigService.get(soClient, packageConfig.config_id); @@ -104,6 +104,7 @@ class PackageConfigService { // Assign it to the given agent config await agentConfigService.assignPackageConfigs(soClient, packageConfig.config_id, [newSo.id], { user: options?.user, + bumpRevision: options?.bumpConfigRevision ?? true, }); return { @@ -117,7 +118,7 @@ class PackageConfigService { soClient: SavedObjectsClientContract, packageConfigs: NewPackageConfig[], configId: string, - options?: { user?: AuthenticatedUser } + options?: { user?: AuthenticatedUser; bumpConfigRevision?: boolean } ): Promise { const isoDate = new Date().toISOString(); const { saved_objects: newSos } = await soClient.bulkCreate( @@ -142,6 +143,7 @@ class PackageConfigService { newSos.map((newSo) => newSo.id), { user: options?.user, + bumpRevision: options?.bumpConfigRevision ?? true, } ); diff --git a/x-pack/plugins/ingest_manager/server/services/setup.ts b/x-pack/plugins/ingest_manager/server/services/setup.ts index 627abc158143d..c91cae98e17d2 100644 --- a/x-pack/plugins/ingest_manager/server/services/setup.ts +++ b/x-pack/plugins/ingest_manager/server/services/setup.ts @@ -218,5 +218,7 @@ async function addPackageToConfig( config.namespace ); - await packageConfigService.create(soClient, callCluster, newPackageConfig); + await packageConfigService.create(soClient, callCluster, newPackageConfig, { + bumpConfigRevision: false, + }); }