From 3ea73978ee1d8417f9b6dd7d5d7bafb1cad5ec87 Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Thu, 10 Jul 2025 11:16:45 +0800 Subject: [PATCH] fix: find the correct vmim based on creationTimeStamp (#389) Signed-off-by: Andy Lee --- .../detail/kubevirt.io.virtualmachine/index.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/harvester/detail/kubevirt.io.virtualmachine/index.vue b/pkg/harvester/detail/kubevirt.io.virtualmachine/index.vue index 6f49e5b6..de924ebf 100644 --- a/pkg/harvester/detail/kubevirt.io.virtualmachine/index.vue +++ b/pkg/harvester/detail/kubevirt.io.virtualmachine/index.vue @@ -139,10 +139,18 @@ export default { const inStore = this.$store.getters['currentProduct'].inStore; const vmimList = this.$store.getters[`${ inStore }/all`](HCI.VMIM) || []; - const migrationUid = this.vmi?.status?.migrationState?.migrationUid; - const vmim = vmimList.find((VMIM) => VMIM?.metadata?.uid === migrationUid); + const vmiName = this.vmi?.name || ''; - return vmim; + // filter the corresponding vmims by vmim.spec.vmiName and find the latest one by creationTimestamp + const vmim = vmimList.filter((VMIM) => VMIM?.spec?.vmiName === vmiName).sort((a, b) => { + if (a?.metadata?.creationTimestamp > b?.metadata?.creationTimestamp) { + return -1; + } + + return 1; + }); + + return vmim.length > 0 && vmim[0] ? vmim[0] : null; }, migrationEvents() {