From 059180a014918a00337dd6fe5f38bfd608320f34 Mon Sep 17 00:00:00 2001 From: johnny19941216 Date: Fri, 23 Dec 2022 18:23:58 +0800 Subject: [PATCH] fix(console): vm status is running but not ready --- .../pages/detail/info/index.tsx | 7 +++- .../virtual-machine/pages/list/index.tsx | 35 ++++++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/web/console/src/modules/cluster/components/resource/virtual-machine/pages/detail/info/index.tsx b/web/console/src/modules/cluster/components/resource/virtual-machine/pages/detail/info/index.tsx index c5b6e3e7c..a53db478c 100644 --- a/web/console/src/modules/cluster/components/resource/virtual-machine/pages/detail/info/index.tsx +++ b/web/console/src/modules/cluster/components/resource/virtual-machine/pages/detail/info/index.tsx @@ -10,10 +10,15 @@ export const VMInfoPanel = ({ clusterId, namespace, name }) => { async () => { const { vm, vmi } = await virtualMachineAPI.fetchVMDetail({ clusterId, namespace, name }); + let realStatus = vm?.status?.printableStatus; + if (realStatus === 'Running' && !vm?.status?.ready) { + realStatus = 'Abnormal'; + } + return { data: { description: vm?.metadata?.annotations?.description ?? '-', - status: vm?.status?.printableStatus, + status: realStatus, createTime: vm?.metadata?.creationTimestamp, tags: Object.entries(vmi?.metadata?.labels ?? []) .map(([key, value]) => `${key}:${value}`) diff --git a/web/console/src/modules/cluster/components/resource/virtual-machine/pages/list/index.tsx b/web/console/src/modules/cluster/components/resource/virtual-machine/pages/list/index.tsx index 4ae519307..e146b6a9a 100644 --- a/web/console/src/modules/cluster/components/resource/virtual-machine/pages/list/index.tsx +++ b/web/console/src/modules/cluster/components/resource/virtual-machine/pages/list/index.tsx @@ -137,18 +137,29 @@ export const VMListPanel = ({ route }) => { ); return { data: - items.map(({ metadata, status, spec, vmi }) => ({ - name: metadata?.name, - status: status?.printableStatus, - mirror: metadata?.annotations?.['tkestack.io/image-display-name'] ?? '-', - ip: vmi?.status?.interfaces?.[0]?.ipAddress ?? '-', - hardware: `${spec?.template?.spec?.domain?.cpu?.cores ?? '-'}核 / ${ - spec?.template?.spec?.domain?.resources?.requests?.memory ?? '-' - }`, - createTime: metadata?.creationTimestamp, - - id: metadata?.uid - })) ?? [], + items.map(({ metadata, status, spec, vmi }) => { + let realStatus = status?.printableStatus; + if (realStatus === 'Running' && !status?.ready) { + realStatus = 'Abnormal'; + } + + const failureCondition = + realStatus === 'Stopped' ? status?.conditions?.find(({ type }) => type === 'Failure') : null; + + return { + name: metadata?.name, + status: realStatus, + failureCondition, + mirror: metadata?.annotations?.['tkestack.io/image-display-name'] ?? '-', + ip: vmi?.status?.interfaces?.[0]?.ipAddress ?? '-', + hardware: `${spec?.template?.spec?.domain?.cpu?.cores ?? '-'}核 / ${ + spec?.template?.spec?.domain?.resources?.requests?.memory ?? '-' + }`, + createTime: metadata?.creationTimestamp, + + id: metadata?.uid + }; + }) ?? [], continueToken: newContinueToken,