From cea835fba73a6c3c083dd80b28073659f0352167 Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Thu, 26 Jan 2023 15:00:51 +0100 Subject: [PATCH] reporting failed status if action result has error --- x-pack/plugins/fleet/common/types/models/agent.ts | 2 +- .../components/agent_diagnostics/index.tsx | 2 +- x-pack/plugins/fleet/server/services/agents/uploads.ts | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/fleet/common/types/models/agent.ts b/x-pack/plugins/fleet/common/types/models/agent.ts index b3beb3d6cdec7..fb7c513762784 100644 --- a/x-pack/plugins/fleet/common/types/models/agent.ts +++ b/x-pack/plugins/fleet/common/types/models/agent.ts @@ -161,7 +161,7 @@ export interface AgentDiagnostics { name: string; createTime: string; filePath: string; - status: 'READY' | 'AWAITING_UPLOAD' | 'DELETED' | 'IN_PROGRESS'; + status: 'READY' | 'AWAITING_UPLOAD' | 'DELETED' | 'IN_PROGRESS' | 'FAILED'; actionId: string; } diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_diagnostics/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_diagnostics/index.tsx index 72b0bd18a555d..b0a588a1d12c4 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_diagnostics/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_diagnostics/index.tsx @@ -132,7 +132,7 @@ export const AgentDiagnosticsTab: React.FunctionComponent ) : ( - +   diff --git a/x-pack/plugins/fleet/server/services/agents/uploads.ts b/x-pack/plugins/fleet/server/services/agents/uploads.ts index a73525d7efc4a..6085ef1e5b801 100644 --- a/x-pack/plugins/fleet/server/services/agents/uploads.ts +++ b/x-pack/plugins/fleet/server/services/agents/uploads.ts @@ -72,7 +72,7 @@ export async function getAgentUploads( const result = { actionId: action.actionId, id: file?.id ?? action.actionId, - status: file?.Status ?? 'IN_PROGRESS', + status: file?.Status ?? (action.error ? 'FAILED' : 'IN_PROGRESS'), name: fileName, createTime: action.timestamp!, filePath, @@ -86,7 +86,7 @@ export async function getAgentUploads( async function _getRequestDiagnosticsActions( esClient: ElasticsearchClient, agentId: string -): Promise> { +): Promise> { const agentActionRes = await esClient.search({ index: AGENT_ACTIONS_INDEX, ignore_unavailable: true, @@ -144,6 +144,7 @@ async function _getRequestDiagnosticsActions( actionId: hit._source?.action_id as string, timestamp: hit._source?.['@timestamp'], fileId: hit._source?.data?.file_id as string, + error: hit._source?.error, })); return agentActions.map((action) => { const actionResult = actionResults.find((result) => result.actionId === action.actionId); @@ -151,6 +152,7 @@ async function _getRequestDiagnosticsActions( actionId: action.actionId, timestamp: actionResult?.timestamp ?? action.timestamp, fileId: actionResult?.fileId, + error: actionResult?.error, }; }); } catch (err) {