From 8ce91ac4d6fae47b1005962eecff4e844e4de054 Mon Sep 17 00:00:00 2001 From: Julia Bardi <90178898+juliaElastic@users.noreply.github.com> Date: Thu, 6 Oct 2022 18:25:41 +0200 Subject: [PATCH] capping ack count not to exceed total actioned count (#142848) --- x-pack/plugins/fleet/server/services/agents/action_status.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/fleet/server/services/agents/action_status.ts b/x-pack/plugins/fleet/server/services/agents/action_status.ts index a057af185a066..7ab162b0aef79 100644 --- a/x-pack/plugins/fleet/server/services/agents/action_status.ts +++ b/x-pack/plugins/fleet/server/services/agents/action_status.ts @@ -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);