Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ingest Manager] Do not bumb config revision during config creation #72270

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}