mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-06 22:26:05 +08:00
feat: expose KubeVirt high-performance storage features in VM and Volume UI (#1133)
* feat: expose KubeVirt high-performance storage features in VM and Volume UI Adds UI to configure KubeVirt high-performance disk/storage settings that were previously only reachable via VMBuilder/Terraform: - Per-volume "Storage Performance Options": a performance profile (Default / High Performance / Custom) exposing per-disk cache, io and dedicatedIOThread on all disk types (VM image/root, new, existing, container) and on the standalone Volume form. - VM-wide "High Performance (I/O Threads and Multi-Queue)": blockMultiQueue and ioThreadsPolicy (+ supplemental-pool thread count), shown only in the VM section since these are domain-level and cannot be set per-PVC. - Compatibility guardrails: io=native forces cache=none; cache=none on Filesystem volumeMode warns; blockMultiQueue requires a virtio disk. Ref: harvester/harvester#11550 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Alejandro Bonilla <abonilla@suse.com> * fix: address review feedback on high-performance storage UI Resolves the Copilot review comments on #1133: - Gate the whole feature behind a new `highPerformanceStorage` release feature flag (v1.9.0) so older supported clusters never render the controls or receive unsupported KubeVirt fields. - Force Cache Mode to "none" whenever Native I/O is selected, including from the "Default" ('') cache value, and disable every non-"none" cache option (Default included) while Native is active. Previously the empty cache value slipped past the guardrail and produced an invalid combo. - Clear an already-enabled blockMultiQueue when the last virtio disk is removed, so a disabled checkbox can no longer persist an invalid setting. - Strip stale cache/io/dedicatedIOThread fields from the merged disk spec when a regenerated disk no longer requests them, so switching a disk back to "Default" (or unchecking Dedicated I/O Thread) while editing no longer silently preserves the previous values. - Expose the disclosure toggle's state to assistive tech via aria-expanded and an expand/collapse aria-label. - Add unit tests for the profile transitions and the Native/cache guardrails. Ref: harvester/harvester#11550 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Alejandro Bonilla <abonilla@suse.com> * fix: address second-round review on high-performance storage UI Resolves the two Copilot findings on #1133 and votdev's UX feedback on harvester/harvester#11550: - Restore the disk's original bus when the performance profile goes back to "Default". The "High Performance" preset switches the bus to virtio, but leaving the preset only cleared cache/io/dedicatedIOThread, so a SATA/SCSI disk was silently left on virtio — a bus change that can make an existing guest unbootable. The pre-preset bus is now remembered and put back, unless the user picked a different bus themselves in the meantime. - Pass the VM-wide performance values from the VM detail page to the shared Volume component. The mixin already parsed them via getInitConfig(), but the detail caller never forwarded them, so VMPerformanceOptions fell back to its prop defaults and hid itself in view mode — configured blockMultiQueue / ioThreadsPolicy settings were invisible. They are also refreshed in the value watcher so the panel does not go stale. - Make the VM-wide "High Performance" panel expandable/collapsible, matching the per-volume "Storage Performance Options" disclosure. It stays collapsed unless the VM already has something configured, so the average user is not faced with specialist tuning controls by default. - Fix the unit tests to use Vue Test Utils v2 mount options. They used the v1 top-level `mocks` key, which VTU 2.x ignores, so every case failed on mount. The repo has no jest config or test script, so this was not caught. Add coverage for the bus save/restore behaviour. Ref: harvester/harvester#11550 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Alejandro Bonilla <abonilla@suse.com> --------- Signed-off-by: Alejandro Bonilla <abonilla@suse.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
3c92a06268
commit
528255dea4
+321
@@ -0,0 +1,321 @@
|
||||
<script>
|
||||
import LabeledSelect from '@shell/components/form/LabeledSelect';
|
||||
import { Checkbox } from '@components/Form/Checkbox';
|
||||
import { Banner } from '@components/Banner';
|
||||
import { _VIEW } from '@shell/config/query-params';
|
||||
import { DISK_CACHE_MODE, DISK_IO_MODE, DISK_PERFORMANCE_PROFILE } from '../../../config/harvester-map';
|
||||
|
||||
const { DEFAULT, HIGH, CUSTOM } = DISK_PERFORMANCE_PROFILE;
|
||||
|
||||
export default {
|
||||
name: 'DiskPerformanceOptions',
|
||||
|
||||
components: {
|
||||
LabeledSelect, Checkbox, Banner
|
||||
},
|
||||
|
||||
emits: ['update'],
|
||||
|
||||
props: {
|
||||
// The disk row. This component reads/writes value.cache, value.io,
|
||||
// value.dedicatedIOThread and (for the "High Performance" preset) value.bus.
|
||||
value: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'create'
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
const hasPerf = !!(this.value.cache || this.value.io || this.value.dedicatedIOThread);
|
||||
|
||||
return {
|
||||
DISK_PERFORMANCE_PROFILE,
|
||||
expanded: hasPerf,
|
||||
profile: this.detectProfile(),
|
||||
// Bus the disk used before the "High Performance" preset switched it to
|
||||
// virtio, so returning to "Default" can put it back.
|
||||
busBeforeHighProfile: null,
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
isView() {
|
||||
return this.mode === _VIEW;
|
||||
},
|
||||
|
||||
storagePerformanceEnabled() {
|
||||
return this.$store.getters['harvester-common/getFeatureEnabled']('highPerformanceStorage');
|
||||
},
|
||||
|
||||
isCdRom() {
|
||||
return this.value.type === 'cd-rom';
|
||||
},
|
||||
|
||||
isCustom() {
|
||||
return this.profile === CUSTOM;
|
||||
},
|
||||
|
||||
isNativeIo() {
|
||||
return this.value.io === 'native';
|
||||
},
|
||||
|
||||
profileOptions() {
|
||||
return [DEFAULT, HIGH, CUSTOM].map((value) => ({
|
||||
label: this.t(`harvester.virtualMachine.volume.performance.profile.${ value }`),
|
||||
value,
|
||||
}));
|
||||
},
|
||||
|
||||
cacheOptions() {
|
||||
return DISK_CACHE_MODE.map((value) => ({
|
||||
label: this.cacheLabel(value),
|
||||
value,
|
||||
// Native AIO only works with an uncached (O_DIRECT) disk, so while it is
|
||||
// selected the only valid cache option is "none" — disable everything
|
||||
// else, including "Default", to prevent an invalid combination.
|
||||
disabled: this.isNativeIo && value !== 'none',
|
||||
}));
|
||||
},
|
||||
|
||||
ioOptions() {
|
||||
return DISK_IO_MODE.map((value) => ({
|
||||
label: value === '' ? this.t('harvester.virtualMachine.volume.performance.ioMode.default') : this.t(`harvester.virtualMachine.volume.performance.ioMode.${ value }`),
|
||||
value,
|
||||
}));
|
||||
},
|
||||
|
||||
showFilesystemCacheWarning() {
|
||||
return this.value.cache === 'none' && this.value.volumeMode === 'Filesystem';
|
||||
},
|
||||
|
||||
showBusTip() {
|
||||
const hasPerf = !!(this.value.cache || this.value.io || this.value.dedicatedIOThread);
|
||||
|
||||
return hasPerf && this.value.bus && this.value.bus !== 'virtio';
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
// Keep the profile selector in sync if the row is repopulated (e.g. editing an existing VM).
|
||||
'value.cache'() {
|
||||
this.profile = this.detectProfile();
|
||||
},
|
||||
'value.io'() {
|
||||
this.profile = this.detectProfile();
|
||||
},
|
||||
'value.dedicatedIOThread'() {
|
||||
this.profile = this.detectProfile();
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
detectProfile() {
|
||||
const { cache, io, dedicatedIOThread } = this.value;
|
||||
|
||||
if (!cache && !io && !dedicatedIOThread) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
if (cache === 'none' && io === 'native' && dedicatedIOThread) {
|
||||
return HIGH;
|
||||
}
|
||||
|
||||
return CUSTOM;
|
||||
},
|
||||
|
||||
cacheLabel(value) {
|
||||
if (value === '') {
|
||||
return this.t('harvester.virtualMachine.volume.performance.cacheMode.default');
|
||||
}
|
||||
|
||||
return this.t(`harvester.virtualMachine.volume.performance.cacheMode.${ value }`);
|
||||
},
|
||||
|
||||
onProfileChange(profile) {
|
||||
const previous = this.profile;
|
||||
|
||||
this.profile = profile;
|
||||
|
||||
if (profile === DEFAULT) {
|
||||
this.value.cache = '';
|
||||
this.value.io = '';
|
||||
this.value.dedicatedIOThread = false;
|
||||
|
||||
// "Default" means no overrides, so also undo the virtio bus that the
|
||||
// "High Performance" preset applied. Skip it if the user has since
|
||||
// picked a different bus themselves — that choice is theirs to keep.
|
||||
if (this.busBeforeHighProfile !== null) {
|
||||
if (this.value.bus === 'virtio') {
|
||||
this.value.bus = this.busBeforeHighProfile;
|
||||
}
|
||||
this.busBeforeHighProfile = null;
|
||||
}
|
||||
} else if (profile === HIGH) {
|
||||
this.value.cache = 'none';
|
||||
this.value.io = 'native';
|
||||
this.value.dedicatedIOThread = true;
|
||||
|
||||
if (previous !== HIGH) {
|
||||
this.busBeforeHighProfile = this.value.bus || '';
|
||||
}
|
||||
this.value.bus = 'virtio';
|
||||
}
|
||||
// CUSTOM keeps whatever is currently set, including the bus.
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
onIoChange(io) {
|
||||
this.value.io = io;
|
||||
// Native AIO requires an uncached disk; force cache to "none" to keep the
|
||||
// combo valid — including when cache is still on its "Default" ('') value,
|
||||
// which libvirt would otherwise reject at domain start.
|
||||
if (io === 'native' && this.value.cache !== 'none') {
|
||||
this.value.cache = 'none';
|
||||
}
|
||||
this.update();
|
||||
},
|
||||
|
||||
update() {
|
||||
this.$emit('update');
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="!isCdRom && storagePerformanceEnabled"
|
||||
class="disk-performance"
|
||||
>
|
||||
<button
|
||||
v-if="!isView"
|
||||
type="button"
|
||||
class="btn btn-sm role-link expand-toggle"
|
||||
:aria-expanded="expanded"
|
||||
:aria-label="expanded ? t('harvester.virtualMachine.volume.performance.collapse') : t('harvester.virtualMachine.volume.performance.expand')"
|
||||
@click.prevent="expanded = !expanded"
|
||||
>
|
||||
<i
|
||||
class="icon"
|
||||
:class="expanded ? 'icon-chevron-down' : 'icon-chevron-right'"
|
||||
/>
|
||||
{{ t('harvester.virtualMachine.volume.performance.title') }}
|
||||
</button>
|
||||
|
||||
<div
|
||||
v-if="expanded || isView"
|
||||
class="perf-body mt-10"
|
||||
>
|
||||
<div class="row mb-20">
|
||||
<div
|
||||
class="col span-6"
|
||||
data-testid="input-disk-perf-profile"
|
||||
>
|
||||
<LabeledSelect
|
||||
:value="profile"
|
||||
:label="t('harvester.virtualMachine.volume.performance.profile.label')"
|
||||
:tooltip="t('harvester.virtualMachine.volume.performance.profile.tip')"
|
||||
:options="profileOptions"
|
||||
:mode="mode"
|
||||
@update:value="onProfileChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Banner
|
||||
v-if="profile === DISK_PERFORMANCE_PROFILE.HIGH"
|
||||
color="info"
|
||||
:label="t('harvester.virtualMachine.volume.performance.highProfileTip')"
|
||||
/>
|
||||
|
||||
<div
|
||||
v-if="isCustom || isView"
|
||||
class="row mb-20"
|
||||
>
|
||||
<div
|
||||
class="col span-6"
|
||||
data-testid="input-disk-cache"
|
||||
>
|
||||
<LabeledSelect
|
||||
v-model:value="value.cache"
|
||||
:label="t('harvester.virtualMachine.volume.performance.cacheMode.label')"
|
||||
:tooltip="t('harvester.virtualMachine.volume.performance.cacheMode.tip')"
|
||||
:options="cacheOptions"
|
||||
:mode="mode"
|
||||
@update:value="update"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="col span-6"
|
||||
data-testid="input-disk-io"
|
||||
>
|
||||
<LabeledSelect
|
||||
:value="value.io"
|
||||
:label="t('harvester.virtualMachine.volume.performance.ioMode.label')"
|
||||
:tooltip="t('harvester.virtualMachine.volume.performance.ioMode.tip')"
|
||||
:options="ioOptions"
|
||||
:mode="mode"
|
||||
@update:value="onIoChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="isCustom || isView"
|
||||
class="row mb-10"
|
||||
>
|
||||
<div
|
||||
class="col span-12"
|
||||
data-testid="input-disk-dedicated-iothread"
|
||||
>
|
||||
<Checkbox
|
||||
v-model:value="value.dedicatedIOThread"
|
||||
:label="t('harvester.virtualMachine.volume.performance.dedicatedIOThread.label')"
|
||||
:tooltip="t('harvester.virtualMachine.volume.performance.dedicatedIOThread.tip')"
|
||||
:mode="mode"
|
||||
@update:value="update"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Banner
|
||||
v-if="isNativeIo"
|
||||
color="info"
|
||||
:label="t('harvester.virtualMachine.volume.performance.ioMode.nativeRequiresNoCacheTip')"
|
||||
/>
|
||||
<Banner
|
||||
v-if="showFilesystemCacheWarning"
|
||||
color="warning"
|
||||
:label="t('harvester.virtualMachine.volume.performance.cacheMode.filesystemWarning')"
|
||||
/>
|
||||
<Banner
|
||||
v-if="showBusTip"
|
||||
color="warning"
|
||||
:label="t('harvester.virtualMachine.volume.performance.busTip')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.disk-performance {
|
||||
border-top: 1px solid var(--border);
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
|
||||
.expand-toggle {
|
||||
padding: 0;
|
||||
font-weight: 600;
|
||||
|
||||
.icon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
<script>
|
||||
import InfoBox from '@shell/components/InfoBox';
|
||||
import LabeledSelect from '@shell/components/form/LabeledSelect';
|
||||
import { LabeledInput } from '@components/Form/LabeledInput';
|
||||
import { Checkbox } from '@components/Form/Checkbox';
|
||||
import { Banner } from '@components/Banner';
|
||||
import { _VIEW } from '@shell/config/query-params';
|
||||
import { IO_THREADS_POLICY } from '../../../config/harvester-map';
|
||||
|
||||
export default {
|
||||
name: 'VMPerformanceOptions',
|
||||
|
||||
components: {
|
||||
InfoBox, LabeledSelect, LabeledInput, Checkbox, Banner
|
||||
},
|
||||
|
||||
emits: ['update:blockMultiQueue', 'update:ioThreadsPolicy', 'update:ioThreadCount'],
|
||||
|
||||
props: {
|
||||
blockMultiQueue: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
|
||||
ioThreadsPolicy: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
|
||||
ioThreadCount: {
|
||||
type: Number,
|
||||
default: 2
|
||||
},
|
||||
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'create'
|
||||
},
|
||||
|
||||
// Whether the current disk set contains a virtio disk (VM context only).
|
||||
hasVirtioDisk: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
|
||||
// Whether any disk requests a dedicated I/O thread (drives the auto-enable hint).
|
||||
hasDedicatedIothread: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
// These are specialist tuning options, so keep the panel collapsed unless the
|
||||
// VM already has something configured.
|
||||
return { expanded: !!(this.blockMultiQueue || this.ioThreadsPolicy) };
|
||||
},
|
||||
|
||||
computed: {
|
||||
isView() {
|
||||
return this.mode === _VIEW;
|
||||
},
|
||||
|
||||
storagePerformanceEnabled() {
|
||||
return this.$store.getters['harvester-common/getFeatureEnabled']('highPerformanceStorage');
|
||||
},
|
||||
|
||||
ioThreadsPolicyOptions() {
|
||||
return IO_THREADS_POLICY.map((value) => ({
|
||||
label: value === '' ? this.t('harvester.virtualMachine.volume.diskPerformance.ioThreadsPolicy.default') : this.t(`harvester.virtualMachine.volume.diskPerformance.ioThreadsPolicy.${ value }`),
|
||||
value,
|
||||
}));
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
// Block Multi-Queue only applies to virtio disks. If the last virtio disk is
|
||||
// removed while it is enabled, clear it so the VM is not left with an invalid
|
||||
// setting the disabled checkbox can no longer surface.
|
||||
hasVirtioDisk(neu) {
|
||||
if (!neu && this.blockMultiQueue) {
|
||||
this.$emit('update:blockMultiQueue', false);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<InfoBox
|
||||
v-if="storagePerformanceEnabled && (!isView || blockMultiQueue || !!ioThreadsPolicy)"
|
||||
class="vm-perf mt-10"
|
||||
>
|
||||
<button
|
||||
v-if="!isView"
|
||||
type="button"
|
||||
class="btn btn-sm role-link expand-toggle"
|
||||
:aria-expanded="expanded"
|
||||
:aria-label="expanded ? t('harvester.virtualMachine.volume.diskPerformance.collapse') : t('harvester.virtualMachine.volume.diskPerformance.expand')"
|
||||
@click.prevent="expanded = !expanded"
|
||||
>
|
||||
<i
|
||||
class="icon"
|
||||
:class="expanded ? 'icon-chevron-down' : 'icon-chevron-right'"
|
||||
/>
|
||||
{{ t('harvester.virtualMachine.volume.diskPerformance.title') }}
|
||||
</button>
|
||||
<h3
|
||||
v-else
|
||||
class="mb-5"
|
||||
>
|
||||
{{ t('harvester.virtualMachine.volume.diskPerformance.title') }}
|
||||
</h3>
|
||||
|
||||
<template v-if="expanded || isView">
|
||||
<p class="text-muted mb-15 mt-10">
|
||||
{{ t('harvester.virtualMachine.volume.diskPerformance.description') }}
|
||||
</p>
|
||||
|
||||
<div class="row mb-10">
|
||||
<div
|
||||
class="col span-12"
|
||||
data-testid="input-vm-block-multi-queue"
|
||||
>
|
||||
<Checkbox
|
||||
:value="blockMultiQueue"
|
||||
:label="t('harvester.virtualMachine.volume.diskPerformance.blockMultiQueue.label')"
|
||||
:tooltip="t('harvester.virtualMachine.volume.diskPerformance.blockMultiQueue.tip')"
|
||||
:mode="mode"
|
||||
:disabled="!hasVirtioDisk"
|
||||
@update:value="$emit('update:blockMultiQueue', $event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<Banner
|
||||
v-if="!hasVirtioDisk && !isView"
|
||||
color="info"
|
||||
:label="t('harvester.virtualMachine.volume.diskPerformance.blockMultiQueue.noVirtioTip')"
|
||||
/>
|
||||
|
||||
<div class="row mb-10">
|
||||
<div
|
||||
class="col span-6"
|
||||
data-testid="input-vm-iothreads-policy"
|
||||
>
|
||||
<LabeledSelect
|
||||
:value="ioThreadsPolicy"
|
||||
:label="t('harvester.virtualMachine.volume.diskPerformance.ioThreadsPolicy.label')"
|
||||
:tooltip="t('harvester.virtualMachine.volume.diskPerformance.ioThreadsPolicy.tip')"
|
||||
:options="ioThreadsPolicyOptions"
|
||||
:mode="mode"
|
||||
@update:value="$emit('update:ioThreadsPolicy', $event)"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-if="ioThreadsPolicy === 'supplementalPool'"
|
||||
class="col span-6"
|
||||
data-testid="input-vm-iothread-count"
|
||||
>
|
||||
<LabeledInput
|
||||
type="number"
|
||||
min="1"
|
||||
:value="ioThreadCount"
|
||||
:label="t('harvester.virtualMachine.volume.diskPerformance.ioThreadCount.label')"
|
||||
:tooltip="t('harvester.virtualMachine.volume.diskPerformance.ioThreadCount.tip')"
|
||||
:mode="mode"
|
||||
@update:value="$emit('update:ioThreadCount', Number($event))"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<Banner
|
||||
v-if="hasDedicatedIothread && !ioThreadsPolicy"
|
||||
color="info"
|
||||
:label="t('harvester.virtualMachine.volume.diskPerformance.ioThreadsPolicy.autoEnabledTip')"
|
||||
/>
|
||||
</template>
|
||||
</InfoBox>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.vm-perf {
|
||||
.expand-toggle {
|
||||
padding: 0;
|
||||
font-weight: 600;
|
||||
|
||||
.icon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { _EDIT } from '@shell/config/query-params';
|
||||
import DiskPerformanceOptions from '../DiskPerformanceOptions.vue';
|
||||
|
||||
const mountOptions = (value, { featureEnabled = true } = {}) => ({
|
||||
props: { value, mode: _EDIT },
|
||||
global: {
|
||||
mocks: {
|
||||
$store: {
|
||||
getters: {
|
||||
'harvester-common/getFeatureEnabled': () => featureEnabled,
|
||||
'i18n/t': (key) => key,
|
||||
'i18n/exists': () => true,
|
||||
}
|
||||
},
|
||||
t: (key) => key,
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
const hardDisk = (overrides = {}) => ({
|
||||
type: 'disk', bus: 'virtio', cache: '', io: '', dedicatedIOThread: false, ...overrides
|
||||
});
|
||||
|
||||
describe('component: DiskPerformanceOptions', () => {
|
||||
it('is hidden when the highPerformanceStorage feature is disabled', () => {
|
||||
const wrapper = mount(DiskPerformanceOptions, mountOptions(hardDisk(), { featureEnabled: false }));
|
||||
|
||||
expect(wrapper.find('.disk-performance').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders for a hard disk when the feature is enabled', () => {
|
||||
const wrapper = mount(DiskPerformanceOptions, mountOptions(hardDisk()));
|
||||
|
||||
expect(wrapper.find('.disk-performance').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('applies the High Performance preset and emits update', () => {
|
||||
const value = hardDisk();
|
||||
const wrapper = mount(DiskPerformanceOptions, mountOptions(value));
|
||||
|
||||
wrapper.vm.onProfileChange('highPerformance');
|
||||
|
||||
expect(value.cache).toBe('none');
|
||||
expect(value.io).toBe('native');
|
||||
expect(value.dedicatedIOThread).toBe(true);
|
||||
expect(value.bus).toBe('virtio');
|
||||
expect(wrapper.emitted('update')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('clears all overrides when switching back to Default', () => {
|
||||
const value = hardDisk({
|
||||
cache: 'none', io: 'native', dedicatedIOThread: true
|
||||
});
|
||||
const wrapper = mount(DiskPerformanceOptions, mountOptions(value));
|
||||
|
||||
wrapper.vm.onProfileChange('default');
|
||||
|
||||
expect(value.cache).toBe('');
|
||||
expect(value.io).toBe('');
|
||||
expect(value.dedicatedIOThread).toBe(false);
|
||||
expect(wrapper.emitted('update')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('restores the original bus when leaving High Performance for Default', () => {
|
||||
const value = hardDisk({ bus: 'sata' });
|
||||
const wrapper = mount(DiskPerformanceOptions, mountOptions(value));
|
||||
|
||||
wrapper.vm.onProfileChange('highPerformance');
|
||||
expect(value.bus).toBe('virtio');
|
||||
|
||||
wrapper.vm.onProfileChange('default');
|
||||
expect(value.bus).toBe('sata');
|
||||
});
|
||||
|
||||
it('keeps a bus the user picked themselves after High Performance', () => {
|
||||
const value = hardDisk({ bus: 'sata' });
|
||||
const wrapper = mount(DiskPerformanceOptions, mountOptions(value));
|
||||
|
||||
wrapper.vm.onProfileChange('highPerformance');
|
||||
value.bus = 'scsi';
|
||||
|
||||
wrapper.vm.onProfileChange('default');
|
||||
expect(value.bus).toBe('scsi');
|
||||
});
|
||||
|
||||
it('leaves the bus alone for a disk that never used the High Performance preset', () => {
|
||||
const value = hardDisk({
|
||||
bus: 'sata', cache: 'writeback', io: 'threads'
|
||||
});
|
||||
const wrapper = mount(DiskPerformanceOptions, mountOptions(value));
|
||||
|
||||
wrapper.vm.onProfileChange('default');
|
||||
expect(value.bus).toBe('sata');
|
||||
});
|
||||
|
||||
it.each([
|
||||
['a cached state', 'writeback'],
|
||||
['the Default cache', ''],
|
||||
])('forces cache to none when Native I/O is selected from %s', (_label, cache) => {
|
||||
const value = hardDisk({ cache });
|
||||
const wrapper = mount(DiskPerformanceOptions, mountOptions(value));
|
||||
|
||||
wrapper.vm.onIoChange('native');
|
||||
|
||||
expect(value.io).toBe('native');
|
||||
expect(value.cache).toBe('none');
|
||||
expect(wrapper.emitted('update')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('disables every cache option except none while Native I/O is active', () => {
|
||||
const wrapper = mount(DiskPerformanceOptions, mountOptions(hardDisk({ io: 'native' })));
|
||||
|
||||
const disabledByValue = wrapper.vm.cacheOptions.reduce((acc, opt) => {
|
||||
acc[opt.value] = opt.disabled;
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
expect(disabledByValue['none']).toBe(false);
|
||||
expect(disabledByValue['']).toBe(true);
|
||||
expect(disabledByValue['writeback']).toBe(true);
|
||||
expect(disabledByValue['writethrough']).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -7,13 +7,14 @@ import UnitInput from '@shell/components/form/UnitInput';
|
||||
import { LabeledInput } from '@components/Form/LabeledInput';
|
||||
import LabeledSelect from '@shell/components/form/LabeledSelect';
|
||||
import ModalWithCard from '@shell/components/ModalWithCard';
|
||||
import VMPerformanceOptions from './VMPerformanceOptions';
|
||||
import { VOLUME_HOTPLUG_ACTION, SOURCE_TYPE } from '../../../config/harvester-map';
|
||||
import { PVC, STORAGE_CLASS } from '@shell/config/types';
|
||||
import { clone } from '@shell/utils/object';
|
||||
import { ucFirst, randomStr } from '@shell/utils/string';
|
||||
import { removeObject } from '@shell/utils/array';
|
||||
import { _VIEW, _EDIT, _CREATE } from '@shell/config/query-params';
|
||||
import { PLUGIN_DEVELOPER, DEV } from '@shell/store/prefs';
|
||||
import { VOLUME_HOTPLUG_ACTION, SOURCE_TYPE } from '../../../config/harvester-map';
|
||||
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../../config/harvester';
|
||||
import { HCI } from '../../../types';
|
||||
import { VOLUME_MODE, ACCESS_MODE } from '@pkg/harvester/config/types';
|
||||
@@ -23,10 +24,10 @@ import { EMPTY_IMAGE } from '../../../utils/vm';
|
||||
const { READ_WRITE_MANY } = ACCESS_MODE;
|
||||
|
||||
export default {
|
||||
emits: ['update:value'],
|
||||
emits: ['update:value', 'update:blockMultiQueue', 'update:ioThreadsPolicy', 'update:ioThreadCount'],
|
||||
|
||||
components: {
|
||||
Banner, BadgeStateFormatter, VueDraggableNext, InfoBox, LabeledInput, UnitInput, LabeledSelect, ModalWithCard
|
||||
Banner, BadgeStateFormatter, VueDraggableNext, InfoBox, LabeledInput, UnitInput, LabeledSelect, ModalWithCard, VMPerformanceOptions
|
||||
},
|
||||
|
||||
props: {
|
||||
@@ -77,6 +78,22 @@ export default {
|
||||
resourceType: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
|
||||
// KubeVirt high-performance VM-level features
|
||||
blockMultiQueue: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
|
||||
ioThreadsPolicy: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
|
||||
ioThreadCount: {
|
||||
type: Number,
|
||||
default: 2
|
||||
}
|
||||
},
|
||||
|
||||
@@ -147,6 +164,14 @@ export default {
|
||||
isLHV2VolExpansionFeatureEnabled() {
|
||||
return this.$store.getters['harvester-common/getFeatureEnabled']('lhV2VolExpansion');
|
||||
},
|
||||
|
||||
hasVirtioDisk() {
|
||||
return this.rows.some((R) => R.type === 'disk' && R.bus === 'virtio');
|
||||
},
|
||||
|
||||
hasDedicatedIOThread() {
|
||||
return this.rows.some((R) => R.dedicatedIOThread);
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
@@ -508,6 +533,18 @@ export default {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<VMPerformanceOptions
|
||||
:block-multi-queue="blockMultiQueue"
|
||||
:io-threads-policy="ioThreadsPolicy"
|
||||
:io-thread-count="ioThreadCount"
|
||||
:has-virtio-disk="hasVirtioDisk"
|
||||
:has-dedicated-iothread="hasDedicatedIOThread"
|
||||
:mode="mode"
|
||||
@update:block-multi-queue="$emit('update:blockMultiQueue', $event)"
|
||||
@update:io-threads-policy="$emit('update:ioThreadsPolicy', $event)"
|
||||
@update:io-thread-count="$emit('update:ioThreadCount', $event)"
|
||||
/>
|
||||
|
||||
<ModalWithCard
|
||||
v-if="isOpen"
|
||||
name="deleteTip"
|
||||
|
||||
+8
-1
@@ -4,6 +4,7 @@ import LabeledSelect from '@shell/components/form/LabeledSelect';
|
||||
import InputOrDisplay from '@shell/components/InputOrDisplay';
|
||||
import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
|
||||
import { Banner } from '@components/Banner';
|
||||
import DiskPerformanceOptions from '../DiskPerformanceOptions';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterEditContainer',
|
||||
@@ -11,7 +12,7 @@ export default {
|
||||
emits: ['update'],
|
||||
|
||||
components: {
|
||||
LabeledInput, LabeledSelect, InputOrDisplay, Banner
|
||||
LabeledInput, LabeledSelect, InputOrDisplay, Banner, DiskPerformanceOptions
|
||||
},
|
||||
|
||||
props: {
|
||||
@@ -153,5 +154,11 @@ export default {
|
||||
class="mb-20"
|
||||
:label="value.volumeBackups.error.message"
|
||||
/>
|
||||
|
||||
<DiskPerformanceOptions
|
||||
:value="value"
|
||||
:mode="mode"
|
||||
@update="update"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+16
-1
@@ -14,6 +14,7 @@ import { VOLUME_MODE } from '@pkg/harvester/config/types';
|
||||
import { HCI } from '../../../../types';
|
||||
import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
|
||||
import { GIBIBYTE } from '../../../../utils/unit';
|
||||
import DiskPerformanceOptions from '../DiskPerformanceOptions';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterEditExisting',
|
||||
@@ -21,7 +22,7 @@ export default {
|
||||
emits: ['update'],
|
||||
|
||||
components: {
|
||||
UnitInput, LabeledInput, LabeledSelect, InputOrDisplay, LabelValue, Banner, Checkbox
|
||||
UnitInput, LabeledInput, LabeledSelect, InputOrDisplay, LabelValue, Banner, Checkbox, DiskPerformanceOptions
|
||||
},
|
||||
|
||||
props: {
|
||||
@@ -172,6 +173,14 @@ export default {
|
||||
this.value.storageClassName = pvcResource.spec.storageClassName;
|
||||
this.value.volumeMode = pvcResource.spec.volumeMode;
|
||||
this.value.shareable = false;
|
||||
|
||||
// Adopt the volume's default high-performance profile (if any) as a starting point.
|
||||
const ann = pvcResource.metadata?.annotations || {};
|
||||
|
||||
this.value.cache = ann[HCI_ANNOTATIONS.DISK_CACHE_MODE] || '';
|
||||
this.value.io = ann[HCI_ANNOTATIONS.DISK_IO_MODE] || '';
|
||||
this.value.dedicatedIOThread = ann[HCI_ANNOTATIONS.DISK_DEDICATED_IOTHREAD] === 'true';
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
@@ -379,5 +388,11 @@ export default {
|
||||
class="mb-20"
|
||||
:label="value.volumeBackups.error.message"
|
||||
/>
|
||||
|
||||
<DiskPerformanceOptions
|
||||
:value="value"
|
||||
:mode="mode"
|
||||
@update="update"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -15,6 +15,7 @@ import LabelValue from '@shell/components/LabelValue';
|
||||
import { ucFirst } from '@shell/utils/string';
|
||||
import { GIBIBYTE } from '../../../../utils/unit';
|
||||
import { EMPTY_IMAGE } from '../../../../utils/vm';
|
||||
import DiskPerformanceOptions from '../DiskPerformanceOptions';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterEditVMImage',
|
||||
@@ -22,7 +23,7 @@ export default {
|
||||
emits: ['update'],
|
||||
|
||||
components: {
|
||||
UnitInput, LabeledInput, LabeledSelect, InputOrDisplay, LabelValue, Banner
|
||||
UnitInput, LabeledInput, LabeledSelect, InputOrDisplay, LabelValue, Banner, DiskPerformanceOptions
|
||||
},
|
||||
|
||||
props: {
|
||||
@@ -482,5 +483,11 @@ export default {
|
||||
color="error"
|
||||
:label="t('harvester.virtualMachine.volume.vmImageVolumeTip', {diskSize: diskSize, imageVirtualSize: imageVirtualSize})"
|
||||
/>
|
||||
|
||||
<DiskPerformanceOptions
|
||||
:value="value"
|
||||
:mode="mode"
|
||||
@update="update"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { formatSi, parseSi } from '@shell/utils/units';
|
||||
import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
|
||||
import { _VIEW } from '@shell/config/query-params';
|
||||
import LabelValue from '@shell/components/LabelValue';
|
||||
import DiskPerformanceOptions from '../DiskPerformanceOptions';
|
||||
import { ucFirst } from '@shell/utils/string';
|
||||
import { LVM_DRIVER } from '../../../../models/harvester/storage.k8s.io.storageclass';
|
||||
import { DATA_ENGINE_V2 } from '../../../../models/harvester/persistentvolumeclaim';
|
||||
@@ -24,7 +25,7 @@ export default {
|
||||
emits: ['update'],
|
||||
|
||||
components: {
|
||||
InputOrDisplay, Loading, LabeledInput, LabeledSelect, UnitInput, LabelValue
|
||||
InputOrDisplay, Loading, LabeledInput, LabeledSelect, UnitInput, LabelValue, DiskPerformanceOptions
|
||||
},
|
||||
|
||||
props: {
|
||||
@@ -362,6 +363,11 @@ export default {
|
||||
</InputOrDisplay>
|
||||
</div>
|
||||
</div>
|
||||
<DiskPerformanceOptions
|
||||
:value="value"
|
||||
:mode="mode"
|
||||
@update="update"
|
||||
/>
|
||||
<div class="row mb-20">
|
||||
<div
|
||||
v-if="value.volumeEncryptionFeatureEnabled && isView"
|
||||
|
||||
Reference in New Issue
Block a user