From 6c27a462748575da1fd6e0f04baf116063f7498f Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Wed, 10 Dec 2025 17:12:56 +0800 Subject: [PATCH] fix: do not inherit template secret when creating new VM (#643) Signed-off-by: Andy Lee --- pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue | 1 - pkg/harvester/mixins/harvester-vm/index.js | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue b/pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue index 8ecdaea8..027b0c49 100644 --- a/pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue +++ b/pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue @@ -96,7 +96,6 @@ export default { templateVersionId: '', namePrefix: '', isSingle: true, - useTemplate: false, isOpen: false, hostname, isRestartImmediately, diff --git a/pkg/harvester/mixins/harvester-vm/index.js b/pkg/harvester/mixins/harvester-vm/index.js index 0df207d1..9c81e5e7 100644 --- a/pkg/harvester/mixins/harvester-vm/index.js +++ b/pkg/harvester/mixins/harvester-vm/index.js @@ -142,6 +142,7 @@ export default { showYaml: false, spec: null, osType: 'linux', + useTemplate: false, sshKey: [], maintenanceStrategies, maintenanceStrategy: 'Migrate', @@ -273,7 +274,7 @@ export default { needNewSecret() { // When creating a template it is always necessary to create a new secret. - return this.showYaml ? false : this.resourceType === HCI.VM_VERSION || this.isCreate; + return this.isCreate || this.showYaml ? false : this.resourceType === HCI.VM_VERSION; }, defaultTerminationSetting() { @@ -1647,7 +1648,8 @@ export default { secretRef: { handler(secret) { - if (secret && this.resourceType !== HCI.BACKUP && this.resourceType !== HCI.VM) { + // we should not inherit the secret if it's from VM template. + if (secret && this.resourceType !== HCI.BACKUP && !this.useTemplate) { this.secretName = secret?.metadata.name; } },