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

[release-4.9] Bug 2046016: SnapShot with Disk Hot-plug hangs #10959

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@
"To take a snapshot you can either edit an existing disk to add a snapshot-supported storage class or add a new disk with a compatible storage class defined. For further details, please contact your cluster admin.": "To take a snapshot you can either edit an existing disk to add a snapshot-supported storage class or add a new disk with a compatible storage class defined. For further details, please contact your cluster admin.",
"Learn more about snapshots": "Learn more about snapshots",
"Take Snapshot": "Take Snapshot",
"Can not create virtual machine snapshot which includes hotplug volume while VM is running": "Can not create virtual machine snapshot which includes hotplug volume while VM is running",
"Snapshot only includes disks backed by a snapshot-supported storage class": "Snapshot only includes disks backed by a snapshot-supported storage class",
"Snapshot Name": "Snapshot Name",
"unsupported approve checkbox": "unsupported approve checkbox",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const SnapshotsModal = withHandlePromise((props: SnapshotsModalProps) => {
cancel,
isVMRunningOrExpectedRunning,
snapshots,
isHotplugExists,
} = props;
const { t } = useTranslation();
const vmName = getName(vmLikeEntity);
Expand All @@ -64,6 +65,7 @@ const SnapshotsModal = withHandlePromise((props: SnapshotsModalProps) => {
const hasUnsupportedVolumes = unsupportedVolumes.length > 0;

const userNeedsToAckWarning = hasUnsupportedVolumes || isVMRunningOrExpectedRunning;
const isLiveSnapshotBlocked = isHotplugExists && isVMRunningOrExpectedRunning;

const submit = async (e) => {
e.preventDefault();
Expand All @@ -87,17 +89,23 @@ const SnapshotsModal = withHandlePromise((props: SnapshotsModalProps) => {
<ModalBody>
{hasSupportedVolumes && (
<Alert
title={t(
'kubevirt-plugin~Snapshot only includes disks backed by a snapshot-supported storage class',
)}
title={
isLiveSnapshotBlocked
? t(
'kubevirt-plugin~Can not create virtual machine snapshot which includes hotplug volume while VM is running',
)
: t(
'kubevirt-plugin~Snapshot only includes disks backed by a snapshot-supported storage class',
)
}
isInline
variant={AlertVariant.info}
className="co-m-form-row"
/>
)}

<Form onSubmit={submit}>
{hasSupportedVolumes && (
{hasSupportedVolumes && !isLiveSnapshotBlocked && (
<>
<FormRow title={t('kubevirt-plugin~Snapshot Name')} fieldId={asId('name')} isRequired>
<TextInput
Expand Down Expand Up @@ -135,7 +143,7 @@ const SnapshotsModal = withHandlePromise((props: SnapshotsModalProps) => {
</FormRow>
)}

{hasSupportedVolumes && userNeedsToAckWarning && (
{hasSupportedVolumes && userNeedsToAckWarning && !isLiveSnapshotBlocked && (
<FormRow fieldId="unsupported-approve-checkbox">
<Checkbox
id="approve-checkbox"
Expand All @@ -153,7 +161,10 @@ const SnapshotsModal = withHandlePromise((props: SnapshotsModalProps) => {
submitButtonText={t('kubevirt-plugin~Save')}
errorMessage={errorMessage}
isDisabled={
inProgress || (hasUnsupportedVolumes && !approveUnsupported) || !hasSupportedVolumes
inProgress ||
(hasUnsupportedVolumes && !approveUnsupported) ||
!hasSupportedVolumes ||
isLiveSnapshotBlocked
}
inProgress={inProgress}
onSubmit={submit}
Expand All @@ -172,5 +183,6 @@ export type SnapshotsModalProps = {
vmLikeEntity: VMLikeEntityKind;
isVMRunningOrExpectedRunning: boolean;
snapshots: VMSnapshot[];
isHotplugExists: boolean;
} & ModalComponentProps &
HandlePromiseProps;
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { VirtualMachineSnapshotModel } from '../../models';
import { kubevirtReferenceForModel } from '../../models/kubevirtReferenceForModel';
import { getName, getNamespace } from '../../selectors';
import { isVMI } from '../../selectors/check-type';
import { getHotplugDiskNames } from '../../selectors/disks/hotplug';
import { getVmSnapshotVmName } from '../../selectors/snapshot/snapshot';
import { isVMRunningOrExpectedRunning } from '../../selectors/vm/selectors';
import { asVM } from '../../selectors/vm/vm';
Expand Down Expand Up @@ -113,6 +114,7 @@ export const VMSnapshotsPage: React.FC<VMTabProps> = ({ obj: vmLikeEntity, vmis:
const filteredSnapshots = snapshots.filter((snap) => getVmSnapshotVmName(snap) === vmName);
const isDisabled = isLocked;

const isHotplugExists = getHotplugDiskNames(vmi)?.length > 0;
return (
<div className="co-m-list">
{!isVMI(vmLikeEntity) && (
Expand All @@ -131,6 +133,7 @@ export const VMSnapshotsPage: React.FC<VMTabProps> = ({ obj: vmLikeEntity, vmis:
vmi,
),
snapshots,
isHotplugExists,
}).result,
)
}
Expand Down