mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-04 21:26:08 +08:00
* 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>
322 lines
8.8 KiB
Vue
322 lines
8.8 KiB
Vue
<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>
|