Skip to content

Commit

Permalink
[Ingest Manager] Do not bumb config revision during config creation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Jul 20, 2020
1 parent 9504c94 commit bf89b3c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const createAgentConfigHandler: RequestHandler<
newSysPackageConfig.namespace = agentConfig.namespace;
await packageConfigService.create(soClient, callCluster, newSysPackageConfig, {
user,
bumpConfigRevision: false,
});
}

Expand Down
10 changes: 6 additions & 4 deletions x-pack/plugins/ingest_manager/server/services/agent_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class AgentConfigService {
soClient: SavedObjectsClientContract,
id: string,
agentConfig: Partial<AgentConfigSOAttributes>,
user?: AuthenticatedUser
user?: AuthenticatedUser,
options: { bumpRevision: boolean } = { bumpRevision: true }
): Promise<AgentConfig> {
const oldAgentConfig = await this.get(soClient, id, false);

Expand All @@ -60,7 +61,7 @@ class AgentConfigService {

await soClient.update<AgentConfigSOAttributes>(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',
});
Expand Down Expand Up @@ -265,7 +266,7 @@ class AgentConfigService {
soClient: SavedObjectsClientContract,
id: string,
packageConfigIds: string[],
options?: { user?: AuthenticatedUser }
options: { user?: AuthenticatedUser; bumpRevision: boolean } = { bumpRevision: true }
): Promise<AgentConfig> {
const oldAgentConfig = await this.get(soClient, id, false);

Expand All @@ -281,7 +282,8 @@ class AgentConfigService {
[...((oldAgentConfig.package_configs || []) as string[])].concat(packageConfigIds)
),
},
options?.user
options?.user,
{ bumpRevision: options.bumpRevision }
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PackageConfig> {
// Check that its agent config does not have a package config with the same name
const parentAgentConfig = await agentConfigService.get(soClient, packageConfig.config_id);
Expand Down Expand Up @@ -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 {
Expand All @@ -117,7 +118,7 @@ class PackageConfigService {
soClient: SavedObjectsClientContract,
packageConfigs: NewPackageConfig[],
configId: string,
options?: { user?: AuthenticatedUser }
options?: { user?: AuthenticatedUser; bumpConfigRevision?: boolean }
): Promise<PackageConfig[]> {
const isoDate = new Date().toISOString();
const { saved_objects: newSos } = await soClient.bulkCreate<PackageConfigSOAttributes>(
Expand All @@ -142,6 +143,7 @@ class PackageConfigService {
newSos.map((newSo) => newSo.id),
{
user: options?.user,
bumpRevision: options?.bumpConfigRevision ?? true,
}
);

Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/ingest_manager/server/services/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,7 @@ async function addPackageToConfig(
config.namespace
);

await packageConfigService.create(soClient, callCluster, newPackageConfig);
await packageConfigService.create(soClient, callCluster, newPackageConfig, {
bumpConfigRevision: false,
});
}

0 comments on commit bf89b3c

Please sign in to comment.