Skip to content

Commit

Permalink
Warn user when restarting BMH
Browse files Browse the repository at this point in the history
  • Loading branch information
rawagner committed Jan 11, 2021
1 parent f0ca5ee commit d7018ed
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
8 changes: 4 additions & 4 deletions frontend/packages/metal3-plugin/locales/en/metal3-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@
"Stop": "Stop",
"Node is under maintenance. The cluster will automatically rebuild node's data 30 minutes after entering maintenance.": "Node is under maintenance. The cluster will automatically rebuild node's data 30 minutes after entering maintenance.",
"Stop maintenance": "Stop maintenance",
"Applications may be temporarily disrupted.": "Applications may be temporarily disrupted.",
"Workloads currently running on this host will not be moved before restarting. This may cause service disruptions.": "Workloads currently running on this host will not be moved before restarting. This may cause service disruptions.",
"Workloads currently running on this host will not be moved before powering off. This may cause service disruptions.": "Workloads currently running on this host will not be moved before powering off. This may cause service disruptions.",
"all workloads have already been moved.": "all workloads have already been moved.",
"all workloads have already been moved, but {{length}} static pods have been skipped.": "all workloads have already been moved, but {{length}} static pods have been skipped.",
"all workloads have already been moved, but {{length}} daemon sets have been skipped.": "all workloads have already been moved, but {{length}} daemon sets have been skipped.",
Expand All @@ -151,8 +154,6 @@
"Workloads will not be moved before the host powers off.": "Workloads will not be moved before the host powers off.",
"The host will power off immediately as if it were unplugged.": "The host will power off immediately as if it were unplugged.",
"Power off immediately": "Power off immediately",
"Applications may be temporarily disrupted.": "Applications may be temporarily disrupted.",
"Workloads currently running on this host will not be moved before powering off. This may cause service disruptions.": "Workloads currently running on this host will not be moved before powering off. This may cause service disruptions.",
"Power Off Host": "Power Off Host",
"Host is ready to be gracefully powered off. The host is currently under maintenance and {{message}}": "Host is ready to be gracefully powered off. The host is currently under maintenance and {{message}}",
"Host is ready to be gracefully powered off.": "Host is ready to be gracefully powered off.",
Expand All @@ -168,9 +169,8 @@
"These DaemonSets will prevent some pods from being moved. This should not prevent the host from powering off gracefully.": "These DaemonSets will prevent some pods from being moved. This should not prevent the host from powering off gracefully.",
"This host contains unmanaged static pods.": "This host contains unmanaged static pods.",
"These pods must be moved manually to continue running after the host powers off.": "These pods must be moved manually to continue running after the host powers off.",
"The bare metal host {{name}} will be restarted gracefully after all managed workloads are moved.": "The bare metal host {{name}} will be restarted gracefully after all managed workloads are moved.",
"The bare metal host {{name}} will be restarted gracefully.": "The bare metal host {{name}} will be restarted gracefully.",
"Restart Bare Metal Host": "Restart Bare Metal Host",
"The host will be powered off and on again.": "The host will be powered off and on again.",
"All managed workloads will be moved off of this node. New workloads and data will not be added to this node until maintenance is stopped.": "All managed workloads will be moved off of this node. New workloads and data will not be added to this node until maintenance is stopped.",
"If the node does not exit maintenance within <1>30 minutes</1>, the cluster will automatically rebuild the node's data using replicated copies": "If the node does not exit maintenance within <1>30 minutes</1>, the cluster will automatically rebuild the node's data using replicated copies",
"The Ceph storage cluster is not in a healthy state.": "The Ceph storage cluster is not in a healthy state.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const PowerOff = (
export const Restart = (
kindObj: K8sKind,
host: BareMetalHostKind,
{ nodeName, bmoEnabled, t }: ActionArgs,
{ bmoEnabled, t }: ActionArgs,
) => ({
hidden:
[HOST_POWER_STATUS_POWERED_OFF, HOST_POWER_STATUS_POWERING_OFF].includes(
Expand All @@ -190,7 +190,7 @@ export const Restart = (
!hasPowerManagement(host) ||
!bmoEnabled,
label: t('metal3-plugin~Restart'),
callback: () => restartHostModal({ host, nodeName }),
callback: () => restartHostModal({ host }),
accessReview: host && asAccessReview(BareMetalHostModel, host, 'update'),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ import { StatusProps } from '../types';
import { StatusValidations, getStaticPods, getDaemonSetsOfPods } from './PowerOffStatusValidations';
import { useMaintenanceCapability } from '../../hooks/useMaintenanceCapability';

type PowerOffWarning = {
restart?: boolean;
};

export const PowerOffWarning: React.FC<PowerOffWarning> = ({ restart }) => {
const { t } = useTranslation();
return (
<Alert
variant="warning"
title={t('metal3-plugin~Applications may be temporarily disrupted.')}
isInline
>
{restart
? t(
'metal3-plugin~Workloads currently running on this host will not be moved before restarting. This may cause service disruptions.',
)
: t(
'metal3-plugin~Workloads currently running on this host will not be moved before powering off. This may cause service disruptions.',
)}
</Alert>
);
};

const getPowerOffMessage = (t: TFunction, pods: PodKind[]) => {
const staticPods = getStaticPods(pods);
const daemonSets = getDaemonSetsOfPods(pods);
Expand Down Expand Up @@ -131,19 +154,7 @@ const ForcePowerOffDialog: React.FC<ForcePowerOffDialogProps> = ({
/>
<div className="text-secondary">{helpText}</div>
</StackItem>
<StackItem>
{forceOff && (
<Alert
variant="warning"
title={t('metal3-plugin~Applications may be temporarily disrupted.')}
isInline
>
{t(
'metal3-plugin~Workloads currently running on this host will not be moved before powering off. This may cause service disruptions.',
)}
</Alert>
)}
</StackItem>
<StackItem>{forceOff && <PowerOffWarning />}</StackItem>
</Stack>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { getName } from '@console/shared';
import { withHandlePromise } from '@console/internal/components/utils';
import {
createModalLauncher,
Expand All @@ -10,10 +9,10 @@ import {
} from '@console/internal/components/factory';
import { BareMetalHostKind } from '../../types';
import { restartHost } from '../../k8s/requests/bare-metal-host';
import { PowerOffWarning } from './PowerOffHostModal';

export type RestartHostModalProps = {
host: BareMetalHostKind;
nodeName: string;
handlePromise: <T>(promise: Promise<T>) => Promise<T>;
inProgress: boolean;
errorMessage: string;
Expand All @@ -23,7 +22,6 @@ export type RestartHostModalProps = {

const RestartHostModal = ({
host,
nodeName,
inProgress,
errorMessage,
handlePromise,
Expand All @@ -41,19 +39,13 @@ const RestartHostModal = ({
[host, close, handlePromise],
);

const text = nodeName
? t(
'metal3-plugin~The bare metal host {{name}} will be restarted gracefully after all managed workloads are moved.',
{ name: getName(host) },
)
: t('metal3-plugin~The bare metal host {{name}} will be restarted gracefully.', {
name: getName(host),
});

return (
<form onSubmit={onSubmit} name="form" className="modal-content">
<ModalTitle>{t('metal3-plugin~Restart Bare Metal Host')}</ModalTitle>
<ModalBody>{text}</ModalBody>
<ModalBody>
<p>{t('metal3-plugin~The host will be powered off and on again.')}</p>
<PowerOffWarning restart />
</ModalBody>
<ModalSubmitFooter
cancel={cancel}
errorMessage={errorMessage}
Expand Down

0 comments on commit d7018ed

Please sign in to comment.