From 796d98e61a4c8fec1ba39a274e38090ac50bec95 Mon Sep 17 00:00:00 2001 From: Yiya Chen Date: Fri, 23 May 2025 15:49:30 +0800 Subject: [PATCH] fix: Harvester upgrade ISO related internal image can be selected to create VM when an upgrade is ongoing (#309) * fix: filter out upgrade image Signed-off-by: Yi-Ya Chen * refactor: add label constant Signed-off-by: Yi-Ya Chen --------- Signed-off-by: Yi-Ya Chen --- pkg/harvester/config/labels-annotations.js | 1 + .../VirtualMachineVolume/type/vmImage.vue | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/pkg/harvester/config/labels-annotations.js b/pkg/harvester/config/labels-annotations.js index 3cc0e693..98a5bbf9 100644 --- a/pkg/harvester/config/labels-annotations.js +++ b/pkg/harvester/config/labels-annotations.js @@ -35,6 +35,7 @@ export const HCI = { NODE_SCHEDULABLE: 'kubevirt.io/schedulable', NETWORK_ROUTE: 'network.harvesterhci.io/route', MATCHED_NODES: 'network.harvesterhci.io/matched-nodes', + UPGRADE: 'harvesterhci.io/upgrade', OS_UPGRADE_IMAGE: 'harvesterhci.io/os-upgrade-image', LATEST_UPGRADE: 'harvesterhci.io/latestUpgrade', UPGRADE_STATE: 'harvesterhci.io/upgradeState', diff --git a/pkg/harvester/edit/kubevirt.io.virtualmachine/VirtualMachineVolume/type/vmImage.vue b/pkg/harvester/edit/kubevirt.io.virtualmachine/VirtualMachineVolume/type/vmImage.vue index 1da8cc8a..219cb605 100644 --- a/pkg/harvester/edit/kubevirt.io.virtualmachine/VirtualMachineVolume/type/vmImage.vue +++ b/pkg/harvester/edit/kubevirt.io.virtualmachine/VirtualMachineVolume/type/vmImage.vue @@ -8,6 +8,7 @@ import { Banner } from '@components/Banner'; import { PVC } from '@shell/config/types'; import { formatSi, parseSi } from '@shell/utils/units'; import { HCI } from '../../../../types'; +import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations'; import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map'; import { _VIEW } from '@shell/config/query-params'; import LabelValue from '@shell/components/LabelValue'; @@ -70,6 +71,7 @@ export default { return { GIBIBYTE, VOLUME_TYPE, + HCI_ANNOTATIONS, InterfaceOption, loading: false, images: [], @@ -90,12 +92,22 @@ export default { }, imagesOption() { - return this.images.filter((c) => c.isReady).sort((a, b) => a.creationTimestamp > b.creationTimestamp ? -1 : 1).map( (I) => { - return { - label: this.imageOptionLabel(I), - value: I.id - }; - }); + return this.images + .filter((image) => { + if (!image.isReady) return false; + + // exclude internal images created during upgrade + const isInternalCreatedImage = + image.namespace === 'harvester-system' && + image.labels?.[HCI_ANNOTATIONS.UPGRADE]; + + return !isInternalCreatedImage; + }) + .sort((a, b) => (a.creationTimestamp > b.creationTimestamp ? -1 : 1)) + .map((image) => ({ + label: this.imageOptionLabel(image), + value: image.id, + })); }, imageName() {