Skip to content

Commit

Permalink
capping ack count not to exceed total actioned count (#142848) (#142885)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8ce91ac)

Co-authored-by: Julia Bardi <[email protected]>
  • Loading branch information
kibanamachine and juliaElastic authored Oct 6, 2022
1 parent ae2459a commit a01cdf7
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 a01cdf7

Please sign in to comment.