Skip to content

Commit

Permalink
capping ack count not to exceed total actioned count (elastic#142848)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic authored Oct 6, 2022
1 parent 4997fdf commit 8ce91ac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions x-pack/plugins/fleet/server/services/agents/action_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ export async function getActionStatuses(
const matchingBucket = (acks?.aggregations?.ack_counts as any)?.buckets?.find(
(bucket: any) => bucket.key === action.actionId
);
const nbAgentsActioned = action.nbAgentsActioned || action.nbAgentsActionCreated;
const nbAgentsAck = Math.min(
matchingBucket?.doc_count ?? 0,
(matchingBucket?.agent_count as any)?.value ?? 0
(matchingBucket?.agent_count as any)?.value ?? 0,
nbAgentsActioned
);
const completionTime = (matchingBucket?.max_timestamp as any)?.value_as_string;
const nbAgentsActioned = action.nbAgentsActioned || action.nbAgentsActionCreated;
const complete = nbAgentsAck >= nbAgentsActioned;
const cancelledAction = cancelledActions.find((a) => a.actionId === action.actionId);

Expand Down

0 comments on commit 8ce91ac

Please sign in to comment.