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
+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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user