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

Add longhorn support message in VM clone dialog #1223

Merged
merged 5 commits into from
Nov 15, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions pkg/harvester/dialog/CloneVmDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,22 @@ export default {
</template>

<template #body>
<Checkbox v-model="cloneData" class="mb-10" label-key="harvester.modal.cloneVM.type" />

<LabeledInput
v-show="cloneData"
v-model="name"
class="mb-20"
:label="t('harvester.modal.cloneVM.name')"
required
/>
<template v-if="!actionResource?.longhornV2Volumes.length">
<Checkbox v-model="cloneData" class="mb-10" label-key="harvester.modal.cloneVM.type" />

<LabeledInput
v-show="cloneData"
v-model="name"
class="mb-20"
:label="t('harvester.modal.cloneVM.name')"
required
/>
</template>
<template v-else>
<Banner color="warning">
<t k="harvester.modal.cloneVM.message.support.longhorn" :raw="true" />
Copy link
Collaborator

@a110605 a110605 Nov 15, 2024

Choose a reason for hiding this comment

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

nit: it's fine to hard code the doc url wthin en-us.yaml in harvester/dashboard as we will only maintain v1.4.x release in this repo.

But when we port the same change to harvester/harvester-ui-extension. The doc link should be varaible. Like

<t k="harvester.setting.storageNetwork.tip" :raw="true" :url="storageNetworkExampleLink" />

</Banner>
</template>
</template>

<div slot="actions" class="actions">
Expand All @@ -109,6 +116,7 @@ export default {
</button>

<AsyncButton
v-if="!actionResource?.longhornV2Volumes.length"
mode="create"
:action-label="cloneData ? t('harvester.modal.cloneVM.action.create') : t('harvester.modal.cloneVM.action.clone')"
:disabled="cloneData && !name"
Expand Down
50 changes: 29 additions & 21 deletions pkg/harvester/dialog/HarvesterExportImageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,34 @@ export default {
</template>

<template #body>
<LabeledSelect
v-model="namespace"
:label="t('harvester.modal.exportImage.namespace')"
:options="namespaces"
class="mb-20"
required
/>

<LabeledInput
v-model="name"
:label="t('harvester.modal.exportImage.name')"
required
/>

<LabeledSelect
v-model="storageClassName"
:options="storageClassOptions"
:label="t('harvester.storage.storageClass.label')"
class="mt-20"
required
/>
<template v-if="actionResource?.isLonghornV2">
<Banner color="warning">
<t k="harvester.modal.exportImage.message.support.longhorn" :raw="true" />
</Banner>
</template>
<template v-else>
<LabeledSelect
v-model="namespace"
:label="t('harvester.modal.exportImage.namespace')"
:options="namespaces"
class="mb-20"
required
/>

<LabeledInput
v-model="name"
:label="t('harvester.modal.exportImage.name')"
required
/>

<LabeledSelect
v-model="storageClassName"
:options="storageClassOptions"
:label="t('harvester.storage.storageClass.label')"
class="mt-20"
required
/>
</template>
</template>

<div slot="actions" class="actions">
Expand All @@ -171,6 +178,7 @@ export default {
</button>

<AsyncButton
v-if="!actionResource?.isLonghornV2"
mode="create"
:disabled="disableSave"
@click="save"
Expand Down
29 changes: 25 additions & 4 deletions pkg/harvester/dialog/HarvesterVMSnapshotDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default {
'growl/success',
{
title: this.t('generic.notification.title.succeed'),
message: this.t('harvester.modal.vmSnapshot.success', { name: this.snapshotName })
message: this.t('harvester.modal.vmSnapshot.message.success', { name: this.snapshotName })
},
{ root: true }
);
Expand Down Expand Up @@ -118,8 +118,24 @@ export default {
/>

<template #body>
<LabeledInput v-model="actionResource.metadata.namespace" :disabled="true" :label="t('generic.namespace')" />
<LabeledInput v-model="snapshotName" class="mt-20" :label="t('generic.name')" required />
<template v-if="actionResource?.longhornV2Volumes.length > 0">
<Banner color="warning">
<t k="harvester.modal.vmSnapshot.message.support.longhorn" :raw="true" />
</Banner>
</template>
<template v-else>
<LabeledInput
v-model="actionResource.metadata.namespace"
:disabled="true"
:label="t('generic.namespace')"
/>
<LabeledInput
v-model="snapshotName"
class="mt-20"
:label="t('generic.name')"
required
/>
</template>
</template>

<div slot="actions" class="actions">
Expand All @@ -128,7 +144,12 @@ export default {
{{ t('generic.cancel') }}
</button>

<AsyncButton mode="create" :disabled="!snapshotName" @click="save" />
<AsyncButton
v-if="!actionResource?.longhornV2Volumes.length"
mode="create"
:disabled="!snapshotName"
@click="save"
/>
</div>

<Banner v-for="(err, i) in errors" :key="i" color="error" :label="err" />
Expand Down
5 changes: 5 additions & 0 deletions pkg/harvester/dialog/SnapshotDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ export default {
{{ t('harvester.modal.snapshot.title') }}
</template>
<template #body>
<Banner v-if="actionResource?.isLonghornV2" color="warning">
<t k="harvester.modal.snapshot.message.support.longhorn" :raw="true" />
</Banner>
<LabeledInput
v-else
v-model="name"
:label="t('harvester.modal.snapshot.name')"
required
Expand All @@ -82,6 +86,7 @@ export default {
{{ t('generic.cancel') }}
</button>
<AsyncButton
v-if="!actionResource?.isLonghornV2"
mode="create"
:disabled="disableSave"
@click="save"
Expand Down
24 changes: 16 additions & 8 deletions pkg/harvester/dialog/VolumeCloneDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,30 @@ export default {
{{ t('harvester.modal.volumeClone.title') }}
</template>
<template #body>
<Checkbox v-model="cloneData" class="mb-10" label-key="harvester.modal.cloneVM.type" />
<template v-if="!actionResource?.isLonghornV2">
<Checkbox v-model="cloneData" class="mb-10" label-key="harvester.modal.cloneVM.type" />

<LabeledInput
v-show="cloneData"
v-model="name"
class="mb-20"
:label="t('harvester.modal.volumeClone.name')"
required
/>
<LabeledInput
v-show="cloneData"
v-model="name"
class="mb-20"
:label="t('harvester.modal.volumeClone.name')"
required
/>
</template>
<template v-else>
<Banner color="warning">
<t k="harvester.modal.volumeClone.message.support.longhorn" :raw="true" />
</Banner>
</template>
</template>
<div slot="actions" class="actions">
<div class="buttons">
<button class="btn role-secondary mr-10" @click="close">
{{ t('generic.cancel') }}
</button>
<AsyncButton
v-if="!actionResource?.isLonghornV2"
mode="create"
:disabled="disableSave"
@click="save"
Expand Down
13 changes: 12 additions & 1 deletion pkg/harvester/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,16 @@ harvester:
tip: Please enter a virtual machine name!
success: 'Virtual machine { name } cloned successfully.'
failed: 'Failed clone virtual machine!'
support:
longhorn: The virtual machine uses Longhorn v2 volumes, which do not <a href="https://docs.harvesterhci.io/v1.4/advanced/longhorn-v2/#limitations" target="_blank">support</a> the Clone action.
exportImage:
title: Export to Image
name: Name
namespace: Namespace
message:
success: 'Image { name } created successfully.'
support:
longhorn: The volume uses Longhorn V2 engine, which does not <a href="https://docs.harvesterhci.io/v1.4/advanced/longhorn-v2/#limitations" target="_blank">support</a> the Export Image action.
migration:
failedMessage: Latest migration failed!
title: Migration
Expand Down Expand Up @@ -108,19 +112,26 @@ harvester:
name: Name
message:
success: 'Take Snapshot { name } successfully.'
support:
longhorn: The volume uses Longhorn V2 engine, which does not <a href="https://docs.harvesterhci.io/v1.4/advanced/longhorn-v2/#limitations" target="_blank">support</a> the Take Snapshot action.
volumeClone:
title: Clone Volume
name: Name
message:
success: 'New Volume { name } cloned successfully.'
support:
longhorn: The volume uses Longhorn V2 engine, which does not <a href="https://docs.harvesterhci.io/v1.4/advanced/longhorn-v2/#limitations" target="_blank">support</a> the Clone action.
restoreSnapshot:
title: Restore Snapshot
name: 'New Volume Name'
success: 'New Volume { name } restored successfully.'
vmSnapshot:
title: Take Virtual Machine Snapshot
name: Name
success: 'Take virtual machine Snapshot { name } successfully.'
message:
success: 'Take virtual machine Snapshot { name } successfully.'
support:
longhorn: The VM uses Longhorn v2 volumes, which do not <a href="https://docs.harvesterhci.io/v1.4/advanced/longhorn-v2/#limitations" target="_blank">support</a> the Take Snapshot action.
restart:
title: Restart Virtual Machine
tip: Restart the virtual machine for configuration changes to take effect.
Expand Down
43 changes: 16 additions & 27 deletions pkg/harvester/models/harvester/persistentvolumeclaim.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,27 @@ export default class HciPv extends HarvesterResource {
}

get availableActions() {
let out = super._availableActions;
const out = super._availableActions;

// Longhorn V2 provisioner do not support volume clone feature yet
if (this.isLonghornV2) {
out = out.filter(action => action.action !== 'goToClone');
} else {
const clone = out.find(action => action.action === 'goToClone');
const clone = out.find(action => action.action === 'goToClone');

if (clone) {
clone.action = 'goToCloneVolume';
}
}

if (!this.isLonghorn || !this.isLonghornV2) {
out = [
{
action: 'exportImage',
enabled: this.hasAction('export') && !this.isEncrypted,
icon: 'icon icon-copy',
label: this.t('harvester.action.exportImage')
},
{
action: 'snapshot',
enabled: this.hasAction('snapshot'),
icon: 'icon icon-backup',
label: this.t('harvester.action.snapshot'),
},
...out
];
if (clone) {
clone.action = 'goToCloneVolume';
}

return [
{
action: 'exportImage',
enabled: this.hasAction('export') && !this.isEncrypted,
icon: 'icon icon-copy',
label: this.t('harvester.action.exportImage')
},
{
action: 'snapshot',
enabled: this.hasAction('snapshot'),
icon: 'icon icon-backup',
label: this.t('harvester.action.snapshot'),
},
{
action: 'cancelExpand',
enabled: this.hasAction('cancelExpand'),
Expand Down
15 changes: 5 additions & 10 deletions pkg/harvester/models/kubevirt.io.virtualmachine.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,12 @@ const IgnoreMessages = ['pod has unbound immediate PersistentVolumeClaims'];

export default class VirtVm extends HarvesterResource {
get availableActions() {
let out = super._availableActions;
const out = super._availableActions;

// VM attached with Longhorn V2 volume doesn't support clone feature
if (this.longhornV2Volumes.length > 0) {
out = out.filter(action => action.action !== 'goToClone');
} else {
const clone = out.find(action => action.action === 'goToClone');
const clone = out.find(action => action.action === 'goToClone');

if (clone) {
clone.action = 'goToCloneVM';
}
if (clone) {
clone.action = 'goToCloneVM';
}

return [
Expand Down Expand Up @@ -157,7 +152,7 @@ export default class VirtVm extends HarvesterResource {
},
{
action: 'takeVMSnapshot',
enabled: !!this.actions?.backup && !this.longhornV2Volumes.length,
enabled: !!this.actions?.backup,
icon: 'icon icon-snapshot',
label: this.t('harvester.action.vmSnapshot')
},
Expand Down
Loading