Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Fleet] Use same action_id for all batches in an upgrade #136663

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion x-pack/plugins/fleet/server/services/agents/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { ElasticsearchClient, SavedObjectsClientContract } from '@kbn/core/server';
import moment from 'moment';
import pMap from 'p-map';
import uuid from 'uuid/v4';

import type { Agent, BulkActionResult, FleetServerAgentAction, CurrentUpgrade } from '../../types';
import {
Expand Down Expand Up @@ -100,6 +101,7 @@ export async function sendUpgradeAgentsActions(
}
}
} else if ('kuery' in options) {
const actionId = uuid();
return await processAgentsInBatches(
esClient,
{
Expand All @@ -108,7 +110,14 @@ export async function sendUpgradeAgentsActions(
batchSize: options.batchSize,
},
async (agents: Agent[], skipSuccess: boolean) =>
await upgradeBatch(soClient, esClient, agents, outgoingErrors, options, skipSuccess)
await upgradeBatch(
soClient,
esClient,
agents,
outgoingErrors,
{ ...options, actionId },
skipSuccess
)
);
}

Expand All @@ -121,6 +130,7 @@ async function upgradeBatch(
givenAgents: Agent[],
outgoingErrors: Record<Agent['id'], Error>,
options: ({ agents: Agent[] } | GetAgentsOptions) & {
actionId?: string;
version: string;
sourceUri?: string | undefined;
force?: boolean;
Expand Down Expand Up @@ -183,6 +193,7 @@ async function upgradeBatch(
);

await createAgentAction(esClient, {
id: options.actionId,
created_at: now,
data,
ack_data: data,
Expand Down