From 492dcbcf23816104a788562035f8eee33abaa72b Mon Sep 17 00:00:00 2001 From: koooge Date: Wed, 22 Nov 2023 22:05:42 +0100 Subject: [PATCH] fix: Fix TypeError of topNodes Signed-off-by: koooge --- src/top.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/top.ts b/src/top.ts index e5f7b33dfc..524eb3aa83 100644 --- a/src/top.ts +++ b/src/top.ts @@ -1,4 +1,4 @@ -import { CoreV1Api, V1Node, V1Pod, V1PodList, V1PodStatus } from './gen/api'; +import { CoreV1Api, V1Node, V1Pod, V1PodList } from './gen/api'; import { Metrics, PodMetric } from './metrics'; import { add, @@ -63,11 +63,7 @@ export async function topNodes(api: CoreV1Api): Promise { let totalPodMem: number | bigint = 0; let totalPodMemLimit: number | bigint = 0; let pods = await podsForNode(api, node.metadata!.name!); - pods = pods.filter( - (pod: V1Pod) => - // @ts-ignore - pod.status!.phase === 'Running' || pod.status!.phase === V1PodStatus.PhaseEnum.Running, - ); + pods = pods.filter((pod: V1Pod) => pod.status?.phase === 'Running'); pods.forEach((pod: V1Pod) => { const cpuTotal = totalCPU(pod); totalPodCPU = add(totalPodCPU, cpuTotal.request);