mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] adding upgrade details UPG_FAILED check to stuck in updating (#173628)
## Summary Closes https://github.com/elastic/kibana/issues/171419 Added upgrade details check to restart upgrade callout when agent is stuck in updating. Changed the copy slightly when the agent has failed upgrade state. <img width="653" alt="image" src="50061732
-aa92-495b-b683-4d96114a1d5a"> Existing copy when there is no upgrade details (stuck in updating for more than 2 hours): <img width="609" alt="image" src="14413c4a
-ce51-49fa-a217-68993c4378fd"> Adjusted Agent list tooltip as well if upgrade details state is failed. <img width="513" alt="image" src="6836e02e
-2c30-4c0a-91ea-8baddb0ccf03"> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
3a41138801
commit
1f3d3eaaa7
6 changed files with 90 additions and 17 deletions
|
@ -61,10 +61,15 @@ export const AGENT_UPDATING_TIMEOUT_HOURS = 2;
|
|||
|
||||
export function isStuckInUpdating(agent: Agent): boolean {
|
||||
return (
|
||||
agent.status === 'updating' &&
|
||||
!!agent.upgrade_started_at &&
|
||||
!agent.upgraded_at &&
|
||||
Date.now() - Date.parse(agent.upgrade_started_at) >
|
||||
AGENT_UPDATING_TIMEOUT_HOURS * 60 * 60 * 1000
|
||||
(agent.status !== 'offline' && agent.active && isAgentInFailedUpgradeState(agent)) ||
|
||||
(agent.status === 'updating' &&
|
||||
!!agent.upgrade_started_at &&
|
||||
!agent.upgraded_at &&
|
||||
Date.now() - Date.parse(agent.upgrade_started_at) >
|
||||
AGENT_UPDATING_TIMEOUT_HOURS * 60 * 60 * 1000)
|
||||
);
|
||||
}
|
||||
|
||||
export function isAgentInFailedUpgradeState(agent: Agent): boolean {
|
||||
return agent.upgrade_details?.state === 'UPG_FAILED';
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ describe('AgentHealth', () => {
|
|||
true
|
||||
);
|
||||
|
||||
utils.getByText('Agent may be stuck updating.');
|
||||
|
||||
act(() => {
|
||||
fireEvent.click(utils.getByTestId('restartUpgradeBtn'));
|
||||
});
|
||||
|
@ -47,6 +49,56 @@ describe('AgentHealth', () => {
|
|||
utils.findByText('Upgrade Modal');
|
||||
});
|
||||
|
||||
it('should render agent health with callout when agent has upgrade state failed', () => {
|
||||
const { utils } = renderAgentHealth(
|
||||
{
|
||||
active: true,
|
||||
status: 'online',
|
||||
upgrade_started_at: '2022-11-21T12:27:24Z',
|
||||
upgrade_details: {
|
||||
state: 'UPG_FAILED',
|
||||
},
|
||||
} as any,
|
||||
true
|
||||
);
|
||||
|
||||
utils.getByText('Agent upgrade is stuck in failed state.');
|
||||
|
||||
utils.getByTestId('restartUpgradeBtn');
|
||||
});
|
||||
|
||||
it('should not render agent health with callout when agent has upgrade state failed but offline', () => {
|
||||
const { utils } = renderAgentHealth(
|
||||
{
|
||||
active: true,
|
||||
status: 'offline',
|
||||
upgrade_started_at: '2022-11-21T12:27:24Z',
|
||||
upgrade_details: {
|
||||
state: 'UPG_FAILED',
|
||||
},
|
||||
} as any,
|
||||
true
|
||||
);
|
||||
|
||||
expect(utils.queryByTestId('restartUpgradeBtn')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render agent health with callout when agent has upgrade state failed but inactive', () => {
|
||||
const { utils } = renderAgentHealth(
|
||||
{
|
||||
active: false,
|
||||
status: 'unenrolled',
|
||||
upgrade_started_at: '2022-11-21T12:27:24Z',
|
||||
upgrade_details: {
|
||||
state: 'UPG_FAILED',
|
||||
},
|
||||
} as any,
|
||||
true
|
||||
);
|
||||
|
||||
expect(utils.queryByTestId('restartUpgradeBtn')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render agent health with callout when agent not stuck updating', () => {
|
||||
const { utils } = renderAgentHealth(
|
||||
{
|
||||
|
@ -58,6 +110,7 @@ describe('AgentHealth', () => {
|
|||
);
|
||||
|
||||
expect(utils.queryByTestId('restartUpgradeBtn')).not.toBeInTheDocument();
|
||||
expect(utils.queryByText('Agent may be stuck updating.')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render agent health with callout when not from details', () => {
|
||||
|
|
|
@ -23,6 +23,7 @@ import { euiLightVars as euiVars } from '@kbn/ui-theme';
|
|||
|
||||
import {
|
||||
getPreviousAgentStatusForOfflineAgents,
|
||||
isAgentInFailedUpgradeState,
|
||||
isStuckInUpdating,
|
||||
} from '../../../../../../common/services/agent_status';
|
||||
|
||||
|
@ -152,12 +153,19 @@ export const AgentHealth: React.FunctionComponent<Props> = ({ agent, fromDetails
|
|||
<p>{lastCheckinText}</p>
|
||||
<p>{lastCheckInMessageText}</p>
|
||||
{isStuckInUpdating(agent) ? (
|
||||
<p>
|
||||
isAgentInFailedUpgradeState(agent) ? (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentHealth.restartUpgradeTooltipText"
|
||||
defaultMessage="Agent may be stuck updating. Consider restarting the upgrade."
|
||||
id="xpack.fleet.agentHealth.failedUpgradeTooltipText"
|
||||
defaultMessage="Agent upgrade failed. Consider restarting the upgrade."
|
||||
/>
|
||||
</p>
|
||||
) : (
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentHealth.restartUpgradeTooltipText"
|
||||
defaultMessage="Agent may be stuck updating. Consider restarting the upgrade."
|
||||
/>
|
||||
</p>
|
||||
)
|
||||
) : null}
|
||||
</>
|
||||
}
|
||||
|
@ -183,17 +191,27 @@ export const AgentHealth: React.FunctionComponent<Props> = ({ agent, fromDetails
|
|||
size="m"
|
||||
color="warning"
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentHealth.stuckUpdatingTitle"
|
||||
defaultMessage="Agent may be stuck updating."
|
||||
/>
|
||||
isAgentInFailedUpgradeState(agent) ? (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentHealth.failedUpgradeTitle"
|
||||
defaultMessage="Agent upgrade is stuck in failed state."
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentHealth.stuckUpdatingTitle"
|
||||
defaultMessage="Agent may be stuck updating."
|
||||
/>
|
||||
)
|
||||
}
|
||||
>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentHealth.stuckUpdatingText"
|
||||
defaultMessage="Agent has been updating for a while, and may be stuck. Consider restarting the upgrade. {learnMore}"
|
||||
defaultMessage="{stuckMessage} Consider restarting the upgrade. {learnMore}"
|
||||
values={{
|
||||
stuckMessage: isAgentInFailedUpgradeState(agent)
|
||||
? 'Agent upgrade failed.'
|
||||
: 'Agent has been updating for a while, and may be stuck.',
|
||||
learnMore: (
|
||||
<div>
|
||||
<EuiLink href={docLinks.links.fleet.upgradeElasticAgent} target="_blank">
|
||||
|
|
|
@ -16579,7 +16579,6 @@
|
|||
"xpack.fleet.agentFlyout.standaloneRadioOption": "{standaloneMessage} – Exécutez un agent Elastic Agent de façon autonome pour le configurer et le mettre à jour manuellement sur l'hôte sur lequel il est installé.",
|
||||
"xpack.fleet.agentHealth.checkinMessageText": "Dernier message de vérification : {lastCheckinMessage}",
|
||||
"xpack.fleet.agentHealth.checkInTooltipText": "Dernier archivage le {lastCheckIn}",
|
||||
"xpack.fleet.agentHealth.stuckUpdatingText": "L'agent effectue la mise à jour depuis un certain temps ; il est peut-être bloqué. Envisagez de redémarrer la mise à niveau. {learnMore}",
|
||||
"xpack.fleet.agentList.noFilteredAgentsPrompt": "Aucun agent trouvé. {clearFiltersLink}",
|
||||
"xpack.fleet.agentLogs.logDisabledCallOutDescription": "Mettez à jour la politique de l'agent {settingsLink} pour activer la collecte de logs.",
|
||||
"xpack.fleet.agentLogs.oldAgentWarningTitle": "La vue Logs requiert Elastic Agent 7.11 ou une version ultérieure. Pour mettre à niveau un agent, accédez au menu Actions ou {downloadLink} une version plus récente.",
|
||||
|
|
|
@ -16592,7 +16592,6 @@
|
|||
"xpack.fleet.agentFlyout.standaloneRadioOption": "{standaloneMessage} – Elasticエージェントをスタンドアロンで実行して、エージェントがインストールされているホストで、手動でエージェントを構成および更新します。",
|
||||
"xpack.fleet.agentHealth.checkinMessageText": "前回のチェックインメッセージ:{lastCheckinMessage}",
|
||||
"xpack.fleet.agentHealth.checkInTooltipText": "前回確認日時:{lastCheckIn}",
|
||||
"xpack.fleet.agentHealth.stuckUpdatingText": "エージェントはしばらく更新が止まっている可能性があります。アップグレードの再開を検討してください。{learnMore}",
|
||||
"xpack.fleet.agentList.noFilteredAgentsPrompt": "エージェントが見つかりません。{clearFiltersLink}",
|
||||
"xpack.fleet.agentLogs.logDisabledCallOutDescription": "エージェントのポリシー{settingsLink}を更新して、ログ収集を有効にします。",
|
||||
"xpack.fleet.agentLogs.oldAgentWarningTitle": "ログの表示には、Elastic Agent 7.11以降が必要です。エージェントをアップグレードするには、[アクション]メニューに移動するか、新しいバージョンを{downloadLink}。",
|
||||
|
|
|
@ -16592,7 +16592,6 @@
|
|||
"xpack.fleet.agentFlyout.standaloneRadioOption": "{standaloneMessage} – 独立运行 Elastic 代理,以在安装代理的主机上手动配置和更新代理。",
|
||||
"xpack.fleet.agentHealth.checkinMessageText": "上次签入消息:{lastCheckinMessage}",
|
||||
"xpack.fleet.agentHealth.checkInTooltipText": "上次签入时间 {lastCheckIn}",
|
||||
"xpack.fleet.agentHealth.stuckUpdatingText": "代理已更新一段时间,并可能陷入停滞。请考虑重新开始升级。{learnMore}",
|
||||
"xpack.fleet.agentList.noFilteredAgentsPrompt": "找不到代理。{clearFiltersLink}",
|
||||
"xpack.fleet.agentLogs.logDisabledCallOutDescription": "更新代理的策略 {settingsLink} 以启用日志收集。",
|
||||
"xpack.fleet.agentLogs.oldAgentWarningTitle": "“日志”视图需要 Elastic Agent 7.11 或更高版本。要升级代理,请前往“操作”菜单或{downloadLink}更新的版本。",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue