Skip to content

Commit

Permalink
reporting failed status if action result has error
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Jan 26, 2023
1 parent 7ff346d commit cea835f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const AgentDiagnosticsTab: React.FunctionComponent<AgentDiagnosticsProps>
</EuiText>
) : (
<EuiText color="subdued">
<EuiToolTip content={`File status: ${currentItem?.status}`}>
<EuiToolTip content={`Diagnostics status: ${currentItem?.status}`}>
<EuiIcon type="alert" color="red" />
</EuiToolTip>
&nbsp;
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/fleet/server/services/agents/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -86,7 +86,7 @@ export async function getAgentUploads(
async function _getRequestDiagnosticsActions(
esClient: ElasticsearchClient,
agentId: string
): Promise<Array<{ actionId: string; timestamp?: string; fileId?: string }>> {
): Promise<Array<{ actionId: string; timestamp?: string; fileId?: string; error?: string }>> {
const agentActionRes = await esClient.search<any>({
index: AGENT_ACTIONS_INDEX,
ignore_unavailable: true,
Expand Down Expand Up @@ -144,13 +144,15 @@ 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);
return {
actionId: action.actionId,
timestamp: actionResult?.timestamp ?? action.timestamp,
fileId: actionResult?.fileId,
error: actionResult?.error,
};
});
} catch (err) {
Expand Down

0 comments on commit cea835f

Please sign in to comment.