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 <yiya.chen@suse.com>

* refactor: add label constant

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>

---------

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>
This commit is contained in:
Yiya Chen 2025-05-23 15:49:30 +08:00 committed by GitHub
parent fe32b4372b
commit 796d98e61a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 6 deletions

View File

@ -35,6 +35,7 @@ export const HCI = {
NODE_SCHEDULABLE: 'kubevirt.io/schedulable', NODE_SCHEDULABLE: 'kubevirt.io/schedulable',
NETWORK_ROUTE: 'network.harvesterhci.io/route', NETWORK_ROUTE: 'network.harvesterhci.io/route',
MATCHED_NODES: 'network.harvesterhci.io/matched-nodes', MATCHED_NODES: 'network.harvesterhci.io/matched-nodes',
UPGRADE: 'harvesterhci.io/upgrade',
OS_UPGRADE_IMAGE: 'harvesterhci.io/os-upgrade-image', OS_UPGRADE_IMAGE: 'harvesterhci.io/os-upgrade-image',
LATEST_UPGRADE: 'harvesterhci.io/latestUpgrade', LATEST_UPGRADE: 'harvesterhci.io/latestUpgrade',
UPGRADE_STATE: 'harvesterhci.io/upgradeState', UPGRADE_STATE: 'harvesterhci.io/upgradeState',

View File

@ -8,6 +8,7 @@ import { Banner } from '@components/Banner';
import { PVC } from '@shell/config/types'; import { PVC } from '@shell/config/types';
import { formatSi, parseSi } from '@shell/utils/units'; import { formatSi, parseSi } from '@shell/utils/units';
import { HCI } from '../../../../types'; import { HCI } from '../../../../types';
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations';
import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map'; import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
import { _VIEW } from '@shell/config/query-params'; import { _VIEW } from '@shell/config/query-params';
import LabelValue from '@shell/components/LabelValue'; import LabelValue from '@shell/components/LabelValue';
@ -70,6 +71,7 @@ export default {
return { return {
GIBIBYTE, GIBIBYTE,
VOLUME_TYPE, VOLUME_TYPE,
HCI_ANNOTATIONS,
InterfaceOption, InterfaceOption,
loading: false, loading: false,
images: [], images: [],
@ -90,12 +92,22 @@ export default {
}, },
imagesOption() { imagesOption() {
return this.images.filter((c) => c.isReady).sort((a, b) => a.creationTimestamp > b.creationTimestamp ? -1 : 1).map( (I) => { return this.images
return { .filter((image) => {
label: this.imageOptionLabel(I), if (!image.isReady) return false;
value: I.id
}; // 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() { imageName() {