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] Only show rolling upgrade warning if an outdated agent is selected #136764

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* 2.0.
*/

// Available versions for the upgrade of the Elastic Agent
export const MINIMUM_SUPPORTED_VERSION = '8.3.0';
kpollich marked this conversation as resolved.
Show resolved Hide resolved

// Available versions for the upgrade of the Elastic Agent
export const FALLBACK_VERSIONS = [
'8.2.1',
'8.2.0',
Expand All @@ -23,4 +24,4 @@ export const FALLBACK_VERSIONS = [
'7.17.0',
];

export const MAINTAINANCE_VALUES = [0, 1, 2, 4, 8, 12, 24, 48];
export const MAINTENANCE_VALUES = [0, 1, 2, 4, 8, 12, 24, 48];
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type { EuiComboBoxOptionOption } from '@elastic/eui';

import semverCoerce from 'semver/functions/coerce';
import semverGt from 'semver/functions/gt';
import semverLt from 'semver/functions/lt';
import semverValid from 'semver/functions/valid';

import { getMinVersion } from '../../../../../../../common/services/get_min_max_version';
Expand All @@ -36,7 +37,7 @@ import {
useKibanaVersion,
} from '../../../../hooks';

import { FALLBACK_VERSIONS, MAINTAINANCE_VALUES } from './constants';
import { FALLBACK_VERSIONS, MAINTENANCE_VALUES, MINIMUM_SUPPORTED_VERSION } from './constants';
import { useScheduleDateTime } from './hooks';

export interface AgentUpgradeAgentModalProps {
Expand All @@ -48,6 +49,10 @@ export interface AgentUpgradeAgentModalProps {

const getVersion = (version: Array<EuiComboBoxOptionOption<string>>) => version[0]?.value as string;

function isVersionUnsupported(version: string) {
return semverLt(version, MINIMUM_SUPPORTED_VERSION);
}

export const AgentUpgradeAgentModal: React.FunctionComponent<AgentUpgradeAgentModalProps> = ({
onClose,
agents,
Expand Down Expand Up @@ -93,7 +98,7 @@ export const AgentUpgradeAgentModal: React.FunctionComponent<AgentUpgradeAgentMo
}, [fallbackVersions, minVersion]);
const noVersions = versionOptions[0]?.value === '';

const maintainanceOptions: Array<EuiComboBoxOptionOption<number>> = MAINTAINANCE_VALUES.map(
const maintainanceOptions: Array<EuiComboBoxOptionOption<number>> = MAINTENANCE_VALUES.map(
(option) => ({
label:
option === 0
Expand Down Expand Up @@ -325,14 +330,21 @@ export const AgentUpgradeAgentModal: React.FunctionComponent<AgentUpgradeAgentMo
customOptionText="Input the desired version"
/>
</EuiFormRow>
{!isSingleAgent ? (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this isSingleAgent distinction, but I'm not sure if that's necessary.

Copy link
Member

@nchaulet nchaulet Jul 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do not use the bulk upgrade and do not provide rolling upgrade option for single agent so it probably make no sense to show the warning for single agent.

{Array.isArray(agents) &&
agents.some((agent) =>
isVersionUnsupported(agent.local_metadata?.elastic?.agent?.version)
) ? (
<>
<EuiSpacer size="m" />
<EuiCallOut
color="warning"
title={i18n.translate('xpack.fleet.upgradeAgents.warningCallout', {
defaultMessage: 'Rolling upgrade only available for Elastic Agent versions 8.3+',
})}
title={
<FormattedMessage
id="xpack.fleet.upgradeAgents.warningCallout"
defaultMessage="Rolling upgrades are only available for Elastic Agent versions {version} and higher"
values={{ version: <strong>{MINIMUM_SUPPORTED_VERSION}</strong> }}
/>
}
/>
</>
) : null}
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -13769,7 +13769,6 @@
"xpack.fleet.upgradeAgents.upgradeMultipleTitle": "Mettre à niveau {count, plural, one {l'agent} other {{count} agents} =true {tous les agents sélectionnés}}",
"xpack.fleet.upgradeAgents.upgradeSingleDescription": "Cette action met à niveau l'agent qui s'exécute sur \"{hostName}\" vers la version {version}. Impossible d'annuler cette action. Voulez-vous vraiment continuer ?",
"xpack.fleet.upgradeAgents.upgradeSingleTitle": "Mettre à niveau l'agent",
"xpack.fleet.upgradeAgents.warningCallout": "Mise à niveau propagée uniquement disponible pour Elastic Agent à partir de la version 8.3",
"xpack.fleet.upgradeAgents.warningCalloutErrors": "Erreur lors de la mise à niveau de {count, plural, one {l'agent sélectionné} other {{count} agents sélectionnés}}",
"xpack.fleet.upgradePackagePolicy.pageDescriptionFromUpgrade": "Mettre à niveau cette intégration et déployer les modifications sur la stratégie d'agent sélectionnée",
"xpack.fleet.upgradePackagePolicy.pageTitle": "Mettre à niveau l'intégration",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -13761,7 +13761,6 @@
"xpack.fleet.upgradeAgents.upgradeMultipleTitle": "{count, plural, other {{count}個のエージェント} =true {すべての選択されたエージェント}}をアップグレード",
"xpack.fleet.upgradeAgents.upgradeSingleDescription": "このアクションにより、「{hostName}」で実行中のエージェントがバージョン{version}にアップグレードされます。このアクションは元に戻せません。続行していいですか?",
"xpack.fleet.upgradeAgents.upgradeSingleTitle": "エージェントをアップグレード",
"xpack.fleet.upgradeAgents.warningCallout": "ローリングアップグレードは、Elasticエージェントバージョン8.3以降でのみ使用できます",
"xpack.fleet.upgradeAgents.warningCalloutErrors": "選択した{count, plural,other {{count}個のエージェント}}のアップグレードエラー",
"xpack.fleet.upgradePackagePolicy.pageDescriptionFromUpgrade": "この統合をアップグレードし、選択したエージェントポリシーに変更をデプロイします",
"xpack.fleet.upgradePackagePolicy.pageTitle": "統合のアップグレード",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -13779,7 +13779,6 @@
"xpack.fleet.upgradeAgents.upgradeMultipleTitle": "升级{count, plural, one {代理} other { {count} 个代理} =true {所有选定代理}}",
"xpack.fleet.upgradeAgents.upgradeSingleDescription": "此操作会将“{hostName}”上运行的代理升级到版本 {version}。此操作无法撤消。是否确定要继续?",
"xpack.fleet.upgradeAgents.upgradeSingleTitle": "升级代理",
"xpack.fleet.upgradeAgents.warningCallout": "滚动升级仅适用于 Elastic 代理版本 8.3+",
"xpack.fleet.upgradeAgents.warningCalloutErrors": "升级选定的{count, plural, one {代理} other {{count} 个代理}}时出错",
"xpack.fleet.upgradePackagePolicy.pageDescriptionFromUpgrade": "升级此集成并将更改部署到选定代理策略",
"xpack.fleet.upgradePackagePolicy.pageTitle": "升级集成",
Expand Down