Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Elastic Agent upgrade states UI #167539

Merged
merged 18 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions x-pack/plugins/fleet/common/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ export type AgentActionType =
| 'POLICY_CHANGE'
| 'INPUT_ACTION';

export type AgentUpgradeStateType =
| 'UPG_REQUESTED'
| 'UPG_SCHEDULED'
| 'UPG_DOWNLOADING'
| 'UPG_EXTRACTING'
| 'UPG_REPLACING'
| 'UPG_RESTARTING'
| 'UPG_WATCHING'
| 'UPG_ROLLBACK'
| 'UPG_FAILED';

type FleetServerAgentComponentStatusTuple = typeof FleetServerAgentComponentStatuses;
export type FleetServerAgentComponentStatus = FleetServerAgentComponentStatusTuple[number];

Expand Down Expand Up @@ -89,6 +100,7 @@ interface AgentBase {
unenrollment_started_at?: string;
upgraded_at?: string | null;
upgrade_started_at?: string | null;
upgrade_details?: AgentUpgradeDetails;
access_api_key_id?: string;
default_api_key?: string;
default_api_key_id?: string;
Expand Down Expand Up @@ -249,6 +261,10 @@ export interface FleetServerAgent {
/**
* ID of the API key the Elastic Agent must used to contact Fleet Server
*/
/**
* Upgrade state of the Elastic Agent
*/
upgrade_details?: AgentUpgradeDetails;
access_api_key_id?: string;
agent?: FleetServerAgentMetadata;
/**
Expand Down Expand Up @@ -328,6 +344,7 @@ export interface FleetServerAgent {
*/
outputs?: OutputMap;
}

/**
* An Elastic Agent metadata
*/
Expand Down Expand Up @@ -421,3 +438,15 @@ export interface ActionStatusOptions {
page?: number;
perPage?: number;
}

export interface AgentUpgradeDetails {
target_version: string;
action_id: string;
state: AgentUpgradeStateType;
metadata: {
scheduled_at?: string;
download_percent?: number;
failed_state?: AgentUpgradeStateType;
error_msg?: string;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { Tags } from '../../components/tags';
import type { AgentMetrics } from '../../../../../../../common/types';
import { formatAgentCPU, formatAgentMemory } from '../../services/agent_metrics';

import { AgentUpgradeStatus } from './agent_upgrade_status';

import { EmptyPrompt } from './empty_prompt';

const VERSION_FIELD = 'local_metadata.elastic.agent.version';
Expand Down Expand Up @@ -175,7 +177,7 @@ export const AgentListTable: React.FC<Props> = (props: Props) => {
name: i18n.translate('xpack.fleet.agentList.policyColumnTitle', {
defaultMessage: 'Agent policy',
}),
width: '260px',
width: '185px',
render: (policyId: string, agent: Agent) => {
const agentPolicy = agentPoliciesIndexedById[policyId];
const showWarning = agent.policy_revision && agentPolicy?.revision > agent.policy_revision;
Expand Down Expand Up @@ -276,29 +278,35 @@ export const AgentListTable: React.FC<Props> = (props: Props) => {
{
field: VERSION_FIELD,
sortable: true,
width: '70px',
width: '180px',
name: i18n.translate('xpack.fleet.agentList.versionTitle', {
defaultMessage: 'Version',
}),
render: (version: string, agent: Agent) => (
<EuiFlexGroup gutterSize="none" style={{ minWidth: 0 }} direction="column">
<EuiFlexItem grow={false} className="eui-textNoWrap">
{safeMetadata(version)}
</EuiFlexItem>
{isAgentSelectable(agent) &&
latestAgentVersion &&
isAgentUpgradeable(agent, latestAgentVersion) ? (
<EuiFlexItem grow={false}>
<EuiText color="subdued" size="xs" className="eui-textNoWrap">
<EuiIcon size="m" type="warning" color="warning" />
&nbsp;
<FormattedMessage
id="xpack.fleet.agentList.agentUpgradeLabel"
defaultMessage="Upgrade available"
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
<EuiText size="s" className="eui-textNoWrap">
{safeMetadata(version)}
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<AgentUpgradeStatus
isAgentUpgradable={
!!(
isAgentSelectable(agent) &&
latestAgentVersion &&
isAgentUpgradeable(agent, latestAgentVersion)
)
}
agentUpgradeStartedAt={agent.upgrade_started_at}
agentUpgradedAt={agent.upgraded_at}
agentUpgradeDetails={agent.upgrade_details}
/>
</EuiText>
</EuiFlexItem>
) : null}
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
),
},
Expand Down
Loading