Skip to content

Commit efc466a

Browse files
authored
Merge pull request #1445 from koooge/fix_topnodes_running
fix: Fix TypeError of topNodes
2 parents 1b1a789 + 492dcbc commit efc466a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/top.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CoreV1Api, V1Node, V1Pod, V1PodList, V1PodStatus } from './gen/api';
1+
import { CoreV1Api, V1Node, V1Pod, V1PodList } from './gen/api';
22
import { Metrics, PodMetric } from './metrics';
33
import {
44
add,
@@ -63,11 +63,7 @@ export async function topNodes(api: CoreV1Api): Promise<NodeStatus[]> {
6363
let totalPodMem: number | bigint = 0;
6464
let totalPodMemLimit: number | bigint = 0;
6565
let pods = await podsForNode(api, node.metadata!.name!);
66-
pods = pods.filter(
67-
(pod: V1Pod) =>
68-
// @ts-ignore
69-
pod.status!.phase === 'Running' || pod.status!.phase === V1PodStatus.PhaseEnum.Running,
70-
);
66+
pods = pods.filter((pod: V1Pod) => pod.status?.phase === 'Running');
7167
pods.forEach((pod: V1Pod) => {
7268
const cpuTotal = totalCPU(pod);
7369
totalPodCPU = add(totalPodCPU, cpuTotal.request);

0 commit comments

Comments
 (0)