[Fleet] Remove Fleet server upgrade modal (#142622)

This commit is contained in:
Nicolas Chaulet 2022-10-04 13:18:39 -04:00 committed by GitHub
parent ae07eb2604
commit 87fa95d49e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 26 additions and 294 deletions

View file

@ -5,8 +5,6 @@ properties:
type: string
has_seen_add_data_notice:
type: boolean
has_seen_fleet_migration_notice:
type: boolean
fleet_server_hosts:
type: array
items:

View file

@ -9,7 +9,6 @@ import type { SavedObjectAttributes } from '@kbn/core/public';
export interface BaseSettings {
has_seen_add_data_notice?: boolean;
has_seen_fleet_migration_notice?: boolean;
fleet_server_hosts: string[];
}

View file

@ -1,223 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React, { useCallback, useEffect, useState } from 'react';
import {
EuiButton,
EuiCheckbox,
EuiFlexGroup,
EuiFlexItem,
EuiImage,
EuiLink,
EuiModal,
EuiModalBody,
EuiModalFooter,
EuiModalHeader,
EuiModalHeaderTitle,
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import {
sendGetAgents,
sendGetOneAgentPolicy,
sendPutSettings,
useLink,
useStartServices,
} from '../../../hooks';
import type { PackagePolicy } from '../../../types';
import { FLEET_SERVER_PACKAGE } from '../../../constants';
interface Props {
onClose: () => void;
}
export const FleetServerUpgradeModal: React.FunctionComponent<Props> = ({ onClose }) => {
const { getAssetsPath } = useLink();
const { notifications, cloud, docLinks } = useStartServices();
const isCloud = !!cloud?.cloudId;
const [checked, setChecked] = useState(false);
const [isAgentsAndPoliciesLoaded, setAgentsAndPoliciesLoaded] = useState(false);
// Check if an other agent than the fleet server is already enrolled
useEffect(() => {
async function check() {
try {
const agentPoliciesAlreadyChecked: { [k: string]: boolean } = {};
const res = await sendGetAgents({
page: 1,
perPage: 10,
showInactive: false,
});
if (res.error) {
throw res.error;
}
for (const agent of res.data?.items ?? []) {
if (!agent.policy_id || agentPoliciesAlreadyChecked[agent.policy_id]) {
continue;
}
agentPoliciesAlreadyChecked[agent.policy_id] = true;
const policyRes = await sendGetOneAgentPolicy(agent.policy_id);
const hasFleetServer =
(policyRes.data?.item.package_policies as PackagePolicy[]).some((p: PackagePolicy) => {
return p.package?.name === FLEET_SERVER_PACKAGE;
}) ?? false;
if (!hasFleetServer) {
await sendPutSettings({
has_seen_fleet_migration_notice: true,
});
onClose();
return;
}
}
setAgentsAndPoliciesLoaded(true);
} catch (err) {
notifications.toasts.addError(err, {
title: i18n.translate('xpack.fleet.fleetServerUpgradeModal.errorLoadingAgents', {
defaultMessage: `Error loading agents`,
}),
});
}
}
check();
}, [notifications.toasts, onClose]);
const onChange = useCallback(async () => {
try {
setChecked(!checked);
await sendPutSettings({
has_seen_fleet_migration_notice: !checked,
});
} catch (error) {
notifications.toasts.addError(error, {
title: i18n.translate('xpack.fleet.fleetServerUpgradeModal.failedUpdateTitle', {
defaultMessage: `Error saving settings`,
}),
});
}
}, [checked, setChecked, notifications]);
if (!isAgentsAndPoliciesLoaded) {
return null;
}
return (
<EuiModal onClose={onClose}>
<EuiModalHeader>
<EuiModalHeaderTitle>
<FormattedMessage
id="xpack.fleet.fleetServerUpgradeModal.modalTitle"
defaultMessage="Enroll your agents into Fleet Server"
/>
</EuiModalHeaderTitle>
</EuiModalHeader>
<EuiModalBody>
<EuiImage
size="fullWidth"
src={getAssetsPath('./announcement.jpg')}
alt={i18n.translate('xpack.fleet.fleetServerUpgradeModal.announcementImageAlt', {
defaultMessage: 'Fleet Server upgrade announcement',
})}
/>
<EuiSpacer size="m" />
<EuiText>
{isCloud ? (
<FormattedMessage
id="xpack.fleet.fleetServerUpgradeModal.cloudDescriptionMessage"
defaultMessage="Fleet Server is now available and it provides improved scalability and security. If you already had an APM instance on Elastic Cloud, we've upgraded it to APM & Fleet. If not, you can add one to your deployment for free. {existingAgentsMessage} To continue using Fleet, you must use Fleet Server and install the new version of Elastic Agent on each host."
values={{
existingAgentsMessage: (
<strong>
<FormattedMessage
id="xpack.fleet.fleetServerUpgradeModal.existingAgentText"
defaultMessage="Your existing Elastic Agents have been automatically unenrolled and have stopped sending data."
/>
</strong>
),
}}
/>
) : (
<FormattedMessage
id="xpack.fleet.fleetServerUpgradeModal.onPremDescriptionMessage"
defaultMessage="Fleet Server is now available and it provides improved scalability and security. {existingAgentsMessage} To continue using Fleet, you must install a Fleet Server and the new version of Elastic Agent on each host. Learn more in our {link}."
values={{
existingAgentsMessage: (
<strong>
<FormattedMessage
id="xpack.fleet.fleetServerUpgradeModal.existingAgentText"
defaultMessage="Your existing Elastic Agents have been automatically unenrolled and have stopped sending data."
/>
</strong>
),
link: (
<EuiLink
href={docLinks.links.fleet.upgradeElasticAgent}
external={true}
target="_blank"
>
<FormattedMessage
id="xpack.fleet.fleetServerUpgradeModal.fleetServerMigrationGuide"
defaultMessage="Fleet Server migration guide"
/>
</EuiLink>
),
}}
/>
)}
</EuiText>
<EuiSpacer size="l" />
<EuiText>
<FormattedMessage
id="xpack.fleet.fleetServerUpgradeModal.breakingChangeMessage"
defaultMessage="This is a breaking change, which is why we are making it in a beta release. We are sorry for the inconvenience. Please share {link} if you have questions or need help."
values={{
link: (
<EuiLink href="https://ela.st/fleet-feedback" target="_blank">
<FormattedMessage
id="xpack.fleet.fleetServerUpgradeModal.fleetFeedbackLink"
defaultMessage="feedback"
/>
</EuiLink>
),
}}
/>
</EuiText>
</EuiModalBody>
<EuiModalFooter>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiCheckbox
id="fleetServerModalCheckbox"
label={i18n.translate('xpack.fleet.fleetServerUpgradeModal.checkboxLabel', {
defaultMessage: 'Do not show this message again',
})}
checked={checked}
onChange={onChange}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton fill onClick={onClose}>
<FormattedMessage
id="xpack.fleet.fleetServerUpgradeModal.closeButton"
defaultMessage="Close and get started"
/>
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiModalFooter>
</EuiModal>
);
};

View file

@ -51,9 +51,7 @@ describe('AgentApp', () => {
mockedUseGetSettings.mockReturnValue({
isLoading: false,
data: {
item: {
has_seen_fleet_migration_notice: true,
},
item: {},
},
} as any);
mockedUseAuthz.mockReturnValue({

View file

@ -5,28 +5,20 @@
* 2.0.
*/
import React, { useCallback, useEffect, useState } from 'react';
import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { Router, Route, Switch, useHistory } from 'react-router-dom';
import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FLEET_ROUTING_PATHS } from '../../constants';
import { Loading, Error } from '../../components';
import {
useConfig,
useFleetStatus,
useBreadcrumbs,
useAuthz,
useGetSettings,
useFlyoutContext,
} from '../../hooks';
import { useConfig, useFleetStatus, useBreadcrumbs, useAuthz, useFlyoutContext } from '../../hooks';
import { DefaultLayout, WithoutHeaderLayout } from '../../layouts';
import { AgentListPage } from './agent_list_page';
import { FleetServerRequirementPage, MissingESRequirementsPage } from './agent_requirements_page';
import { AgentDetailsPage } from './agent_details_page';
import { NoAccessPage } from './error_pages/no_access';
import { FleetServerUpgradeModal } from './components/fleet_server_upgrade_modal';
export const AgentsApp: React.FunctionComponent = () => {
useBreadcrumbs('agent_list');
@ -36,20 +28,6 @@ export const AgentsApp: React.FunctionComponent = () => {
const fleetStatus = useFleetStatus();
const flyoutContext = useFlyoutContext();
const settings = useGetSettings();
const [fleetServerModalVisible, setFleetServerModalVisible] = useState(false);
const onCloseFleetServerModal = useCallback(() => {
setFleetServerModalVisible(false);
}, [setFleetServerModalVisible]);
useEffect(() => {
// if it's undefined do not show the modal
if (settings.data && settings.data?.item.has_seen_fleet_migration_notice === false) {
setFleetServerModalVisible(true);
}
}, [settings.data]);
if (!agents.enabled) return null;
if (!fleetStatus.missingRequirements && fleetStatus.isLoading) {
return <Loading />;
@ -114,9 +92,6 @@ export const AgentsApp: React.FunctionComponent = () => {
</Route>
<Route path={FLEET_ROUTING_PATHS.agents}>
<DefaultLayout section="agents" rightColumn={rightColumn}>
{fleetServerModalVisible && (
<FleetServerUpgradeModal onClose={onCloseFleetServerModal} />
)}
{displayInstructions ? (
<FleetServerRequirementPage showEnrollmentRecommendation={false} />
) : (

View file

@ -46,6 +46,7 @@ import {
migratePackagePolicyToV840,
} from './migrations/to_v8_4_0';
import { migratePackagePolicyToV850, migrateAgentPolicyToV850 } from './migrations/to_v8_5_0';
import { migrateSettingsToV860 } from './migrations/to_v8_6_0';
/*
* Saved object types and mappings
@ -56,6 +57,7 @@ import { migratePackagePolicyToV850, migrateAgentPolicyToV850 } from './migratio
const getSavedObjectTypes = (
encryptedSavedObjects: EncryptedSavedObjectsPluginSetup
): { [key: string]: SavedObjectsType } => ({
// Deprecated
[GLOBAL_SETTINGS_SAVED_OBJECT_TYPE]: {
name: GLOBAL_SETTINGS_SAVED_OBJECT_TYPE,
hidden: false,
@ -67,12 +69,12 @@ const getSavedObjectTypes = (
properties: {
fleet_server_hosts: { type: 'keyword' },
has_seen_add_data_notice: { type: 'boolean', index: false },
has_seen_fleet_migration_notice: { type: 'boolean', index: false },
},
},
migrations: {
'7.10.0': migrateSettingsToV7100,
'7.13.0': migrateSettingsToV7130,
'8.6.0': migrateSettingsToV860,
},
},
[AGENT_POLICY_SAVED_OBJECT_TYPE]: {

View file

@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { SavedObjectMigrationFn } from '@kbn/core/server';
import type { Settings } from '../../../common/types';
export const migrateSettingsToV860: SavedObjectMigrationFn<Settings, Settings> = (
settingsDoc,
migrationContext
) => {
// @ts-expect-error has_seen_fleet_migration_notice property does not exists anymore
delete settingsDoc.attributes.has_seen_fleet_migration_notice;
return settingsDoc;
};

View file

@ -23,7 +23,6 @@ export const PutSettingsRequestSchema = {
})
),
has_seen_add_data_notice: schema.maybe(schema.boolean()),
has_seen_fleet_migration_notice: schema.maybe(schema.boolean()),
additional_yaml_config: schema.maybe(schema.string()),
// Deprecated not used
kibana_urls: schema.maybe(

View file

@ -12779,9 +12779,6 @@
"xpack.fleet.fleetServerSetup.deploymentModeProductionOption": "{production} : fournissez vos propres certificats. Cette option demande aux agents de préciser une clé de certificat lors de leur enregistrement avec Fleet",
"xpack.fleet.fleetServerSetup.deploymentModeQuickStartOption": "{quickStart} : le serveur Fleet génère un certificat autosigné. Les agents suivants doivent être enregistrés avec l'indicateur --insecure. Non recommandé pour les cas d'utilisation en production.",
"xpack.fleet.fleetServerSetupPermissionDeniedErrorMessage": "Le serveur Fleet doit être configuré. Pour cela, le privilège de cluster {roleName} est requis. Contactez votre administrateur.",
"xpack.fleet.fleetServerUpgradeModal.breakingChangeMessage": "Il s'agit d'un changement majeur, c'est pourquoi nous l'appliquons dans une version bêta. Nous vous prions de nous excuser pour la gêne occasionnée. Partagez {link} si vous avez des questions ou si vous avez besoin d'aide.",
"xpack.fleet.fleetServerUpgradeModal.cloudDescriptionMessage": "Le serveur Fleet est désormais disponible et renforce la scalabilité et la sécurité. Si vous aviez déjà une instance APM sur Elastic Cloud, nous l'avons mise à niveau vers APM et Fleet. Dans le cas contraire, vous pouvez en ajouter une gratuitement à votre déploiement. {existingAgentsMessage} Pour continuer à utiliser Fleet, vous devez utiliser le serveur Fleet et installer la nouvelle version d'Elastic Agent sur chaque hôte.",
"xpack.fleet.fleetServerUpgradeModal.onPremDescriptionMessage": "Le serveur Fleet est désormais disponible et renforce la scalabilité et la sécurité. {existingAgentsMessage} Pour continuer à utiliser Fleet, vous devez installer un serveur Fleet et la nouvelle version d'Elastic Agent sur chaque hôte. Apprenez-en plus avec notre {link}.",
"xpack.fleet.homeIntegration.tutorialModule.noticeText": "{notePrefix} Une version plus récente de ce module est {availableAsIntegrationLink}. Pour en savoir plus sur les intégrations et le nouvel agent Elastic Agent, lisez notre {blogPostLink}.",
"xpack.fleet.integration.settings.versionInfo.updatesAvailableBody": "Passez à la version {latestVersion} pour bénéficier des fonctionnalités les plus récentes.",
"xpack.fleet.integrations.confirmUpdateModal.body.agentCount": "{agentCount, plural, one {# agent} other {# agents}}",
@ -13508,15 +13505,6 @@
"xpack.fleet.fleetServerSetup.waitingText": "En attente de connexion d'un serveur Fleet…",
"xpack.fleet.fleetServerSetupPermissionDeniedErrorTitle": "Autorisation refusée",
"xpack.fleet.fleetServerUnhealthy.requestError": "Une erreur sest produite lors de la récupération du statut du serveur Fleet.",
"xpack.fleet.fleetServerUpgradeModal.announcementImageAlt": "Annonce de mise à niveau du serveur Fleet",
"xpack.fleet.fleetServerUpgradeModal.checkboxLabel": "Ne plus afficher ce message",
"xpack.fleet.fleetServerUpgradeModal.closeButton": "Fermer et démarrer",
"xpack.fleet.fleetServerUpgradeModal.errorLoadingAgents": "Erreur lors du chargement des agents",
"xpack.fleet.fleetServerUpgradeModal.existingAgentText": "Vos agents Elastic existants ont été désenregistrés automatiquement et ont cessé d'envoyer des données.",
"xpack.fleet.fleetServerUpgradeModal.failedUpdateTitle": "Erreur lors de l'enregistrement des paramètres",
"xpack.fleet.fleetServerUpgradeModal.fleetFeedbackLink": "commentaires",
"xpack.fleet.fleetServerUpgradeModal.fleetServerMigrationGuide": "Guide sur la migration du serveur Fleet",
"xpack.fleet.fleetServerUpgradeModal.modalTitle": "Enregistrer vos agents sur le serveur Fleet",
"xpack.fleet.genericActionsMenuText": "Ouvrir",
"xpack.fleet.homeIntegration.tutorialDirectory.fleetAppButtonText": "Tester les intégrations",
"xpack.fleet.homeIntegration.tutorialModule.noticeText.blogPostLink": "article de blog d'annonce",

View file

@ -12764,9 +12764,6 @@
"xpack.fleet.fleetServerSetup.deploymentModeProductionOption": "{production} 独自の証明書を指定します。このオプションでは、Fleetに登録するときに、エージェントで証明書鍵を指定する必要があります。",
"xpack.fleet.fleetServerSetup.deploymentModeQuickStartOption": "{quickStart} Fleetサーバーは自己署名証明書を生成します。後続のエージェントは--insecureフラグを使用して登録する必要があります。本番ユースケースには推奨されません。",
"xpack.fleet.fleetServerSetupPermissionDeniedErrorMessage": "Fleetサーバーを設定する必要があります。これには{roleName}クラスター権限が必要です。管理者にお問い合わせください。",
"xpack.fleet.fleetServerUpgradeModal.breakingChangeMessage": "これは大きい変更であるため、ベータリリースにしています。ご不便をおかけしていることをお詫び申し上げます。ご質問がある場合や、サポートが必要な場合は、{link}を共有してください。",
"xpack.fleet.fleetServerUpgradeModal.cloudDescriptionMessage": "Fleetサーバーを使用できます。スケーラビリティとセキュリティが強化されました。すでにElastic CloudクラウドにAPMインスタンスがあった場合は、APM &amp; Fleetにアップグレードされました。そうでない場合は、無料でデプロイに追加できます。{existingAgentsMessage}引き続きFleetを使用するには、Fleetサーバーを使用して、各ホストに新しいバージョンのElasticエージェントをインストールする必要があります。",
"xpack.fleet.fleetServerUpgradeModal.onPremDescriptionMessage": "Fleetサーバーが使用できます。スケーラビリティとセキュリティが改善されています。{existingAgentsMessage} Fleetを使用し続けるには、Fleetサーバーと新しいバージョンのElasticエージェントを各ホストにインストールする必要があります。詳細については、{link}をご覧ください。",
"xpack.fleet.homeIntegration.tutorialModule.noticeText": "{notePrefix}このモジュールの新しいバージョンは{availableAsIntegrationLink}です。統合と新しいElasticエージェントの詳細については、{blogPostLink}をお読みください。",
"xpack.fleet.integration.settings.versionInfo.updatesAvailableBody": "バージョン{latestVersion}にアップグレードして最新の機能を入手",
"xpack.fleet.integrations.confirmUpdateModal.body.agentCount": "{agentCount, plural, other {# 個のエージェント}}",
@ -13494,15 +13491,6 @@
"xpack.fleet.fleetServerSetup.waitingText": "Fleetサーバーの接続を待機しています...",
"xpack.fleet.fleetServerSetupPermissionDeniedErrorTitle": "パーミッションが拒否されました",
"xpack.fleet.fleetServerUnhealthy.requestError": "Fleetサーバーステータスの取得中にエラーが発生しました",
"xpack.fleet.fleetServerUpgradeModal.announcementImageAlt": "Fleetサーバーアップグレード通知",
"xpack.fleet.fleetServerUpgradeModal.checkboxLabel": "次回以降このメッセージを表示しない",
"xpack.fleet.fleetServerUpgradeModal.closeButton": "閉じて開始する",
"xpack.fleet.fleetServerUpgradeModal.errorLoadingAgents": "エージェントの読み込みエラー",
"xpack.fleet.fleetServerUpgradeModal.existingAgentText": "既存のElasticエージェントは自動的に登録解除され、データの送信を停止しました。",
"xpack.fleet.fleetServerUpgradeModal.failedUpdateTitle": "設定の保存エラー",
"xpack.fleet.fleetServerUpgradeModal.fleetFeedbackLink": "フィードバック",
"xpack.fleet.fleetServerUpgradeModal.fleetServerMigrationGuide": "Fleetサーバー移行ガイド",
"xpack.fleet.fleetServerUpgradeModal.modalTitle": "エージェントをFleetサーバーに登録",
"xpack.fleet.genericActionsMenuText": "開く",
"xpack.fleet.homeIntegration.tutorialDirectory.fleetAppButtonText": "統合を試す",
"xpack.fleet.homeIntegration.tutorialModule.noticeText.blogPostLink": "発表ブログ投稿",

View file

@ -12784,9 +12784,6 @@
"xpack.fleet.fleetServerSetup.deploymentModeProductionOption": "{production} 提供您自己的证书。注册到 Fleet 时,此选项将需要代理指定证书密钥",
"xpack.fleet.fleetServerSetup.deploymentModeQuickStartOption": "{quickStart} Fleet 服务器将生成自签名证书。必须使用 --insecure 标志注册后续代理。不推荐用于生产用例。",
"xpack.fleet.fleetServerSetupPermissionDeniedErrorMessage": "需要设置 Fleet 服务器。这需要 {roleName} 集群权限。请联系您的管理员。",
"xpack.fleet.fleetServerUpgradeModal.breakingChangeMessage": "这是一项重大更改,所以我们在公测版中进行该更改。非常抱歉带来不便。如果您有疑问或需要帮助,请共享 {link}。",
"xpack.fleet.fleetServerUpgradeModal.cloudDescriptionMessage": "Fleet 服务器现在可用并提供改善的可扩展性和安全性。如果您在 Elastic Cloud 上已有 APM 实例,则我们已将其升级到 APM 和 Fleet。如果没有可以免费将一个添加到您的部署。{existingAgentsMessage}要继续使用 Fleet必须使用 Fleet 服务器并在每个主机上安装新版 Elastic 代理。",
"xpack.fleet.fleetServerUpgradeModal.onPremDescriptionMessage": "Fleet 服务器现在可用且提供改善的可扩展性和安全性。{existingAgentsMessage}要继续使用 Fleet必须在各个主机上安装 Fleet 服务器和新版 Elastic 代理。详细了解我们的 {link}。",
"xpack.fleet.homeIntegration.tutorialModule.noticeText": "{notePrefix} 此模块的较新版本为 {availableAsIntegrationLink}。要详细了解集成和新 Elastic 代理,请阅读我们的{blogPostLink}。",
"xpack.fleet.integration.settings.versionInfo.updatesAvailableBody": "升级到版本 {latestVersion} 可获取最新功能",
"xpack.fleet.integrations.confirmUpdateModal.body.agentCount": "{agentCount, plural, other {# 个代理}}",
@ -13514,15 +13511,6 @@
"xpack.fleet.fleetServerSetup.waitingText": "等候 Fleet 服务器连接......",
"xpack.fleet.fleetServerSetupPermissionDeniedErrorTitle": "权限被拒绝",
"xpack.fleet.fleetServerUnhealthy.requestError": "提取 Fleet 服务器状态时出错",
"xpack.fleet.fleetServerUpgradeModal.announcementImageAlt": "Fleet 服务器升级公告",
"xpack.fleet.fleetServerUpgradeModal.checkboxLabel": "不再显示此消息",
"xpack.fleet.fleetServerUpgradeModal.closeButton": "关闭并开始使用",
"xpack.fleet.fleetServerUpgradeModal.errorLoadingAgents": "加载代理时出错",
"xpack.fleet.fleetServerUpgradeModal.existingAgentText": "您现有的 Elastic 代理已被自动销注且已停止发送数据。",
"xpack.fleet.fleetServerUpgradeModal.failedUpdateTitle": "保存设置时出错",
"xpack.fleet.fleetServerUpgradeModal.fleetFeedbackLink": "反馈",
"xpack.fleet.fleetServerUpgradeModal.fleetServerMigrationGuide": "Fleet 服务器迁移指南",
"xpack.fleet.fleetServerUpgradeModal.modalTitle": "将代理注册到 Fleet 服务器",
"xpack.fleet.genericActionsMenuText": "打开",
"xpack.fleet.homeIntegration.tutorialDirectory.fleetAppButtonText": "试用集成",
"xpack.fleet.homeIntegration.tutorialModule.noticeText.blogPostLink": "公告博客",