fix: show quotes in high-performance storage hints and keep Custom profile (#1204) (#1219)

* fix: show quotes in high-performance storage hints and keep Custom profile

The Native I/O and I/O threads policy hints were passed to Banner as
:label="t(...)". t() escapes HTML and Banner escapes the label again,
so the quotes showed up as ". Use label-key instead, which renders
the string once.

Picking the Custom performance profile and then choosing options that
match the Default or High Performance preset flipped the selector back
to that preset. Keep an explicit Custom choice and only infer the
profile from the disk values otherwise.

Related: harvester/harvester#11550



* fix: only keep Custom profile when the user picked it

syncProfile() skipped re-detection whenever the profile was Custom,
including a Custom that was inferred from the disk values. In an
existing-volume row, switching from a volume with a WriteBack override
to one with High Performance values left the selector on Custom.

Track the user's explicit Custom choice in its own flag and use that
in the guard, so an inferred Custom still follows the disk values.

Related: harvester/harvester#11550



* test: cover the label-key hints of VMPerformanceOptions

Check that the I/O threads policy and no virtio disk hints are passed to Banner as label keys, so their quotes are not escaped twice, and that the I/O threads policy hint is hidden once a policy is set.



---------


(cherry picked from commit 840f9de73e)

Signed-off-by: Alejandro Bonilla <abonilla@suse.com>
Co-authored-by: Alejandro Bonilla <abonilla@suse.com>
This commit is contained in:
mergify[bot]
2026-11-04 15:08:51 +08:00
committed by GitHub
co-authored by Alejandro Bonilla
parent 754192c8c8
commit 47d337aa7d
4 changed files with 140 additions and 9 deletions
@@ -40,6 +40,8 @@ export default {
// Bus the disk used before the "High Performance" preset switched it to
// virtio, so returning to "Default" can put it back.
busBeforeHighProfile: null,
// True only while the user has explicitly picked "Custom" in the selector.
userSelectedCustom: false,
};
},
@@ -103,13 +105,13 @@ export default {
watch: {
// Keep the profile selector in sync if the row is repopulated (e.g. editing an existing VM).
'value.cache'() {
this.profile = this.detectProfile();
this.syncProfile();
},
'value.io'() {
this.profile = this.detectProfile();
this.syncProfile();
},
'value.dedicatedIOThread'() {
this.profile = this.detectProfile();
this.syncProfile();
},
},
@@ -128,6 +130,16 @@ export default {
return CUSTOM;
},
syncProfile() {
// An explicit "Custom" choice sticks, even if the options happen to
// match the Default or High Performance preset. An inferred "Custom"
// still follows the disk values.
if (this.userSelectedCustom) {
return;
}
this.profile = this.detectProfile();
},
cacheLabel(value) {
if (value === '') {
return this.t('harvester.virtualMachine.volume.performance.cacheMode.default');
@@ -140,6 +152,7 @@ export default {
const previous = this.profile;
this.profile = profile;
this.userSelectedCustom = profile === CUSTOM;
if (profile === DEFAULT) {
this.value.cache = '';
@@ -231,7 +244,7 @@ export default {
<Banner
v-if="profile === DISK_PERFORMANCE_PROFILE.HIGH"
color="info"
:label="t('harvester.virtualMachine.volume.performance.highProfileTip')"
label-key="harvester.virtualMachine.volume.performance.highProfileTip"
/>
<div
@@ -287,17 +300,17 @@ export default {
<Banner
v-if="isNativeIo"
color="info"
:label="t('harvester.virtualMachine.volume.performance.ioMode.nativeRequiresNoCacheTip')"
label-key="harvester.virtualMachine.volume.performance.ioMode.nativeRequiresNoCacheTip"
/>
<Banner
v-if="showFilesystemCacheWarning"
color="warning"
:label="t('harvester.virtualMachine.volume.performance.cacheMode.filesystemWarning')"
label-key="harvester.virtualMachine.volume.performance.cacheMode.filesystemWarning"
/>
<Banner
v-if="showBusTip"
color="warning"
:label="t('harvester.virtualMachine.volume.performance.busTip')"
label-key="harvester.virtualMachine.volume.performance.busTip"
/>
</div>
</div>