Skip to content

topNodes throws TypeError: "TypeError: Cannot read properties of undefined (reading 'Running')" #1447

Closed
@ecksun

Description

@ecksun

Describe the bug
When using k8s.topNodes an exception is thrown:

/home/user/tmp/k8s-client-node/node_modules/@kubernetes/client-node/dist/top.js:61
        pod.status.phase === 'Running' || pod.status.phase === api_1.V1PodStatus.PhaseEnum.Running);
                                                                                           ^

TypeError: Cannot read properties of undefined (reading 'Running')
    at /home/user/tmp/k8s-client-node/node_modules/@kubernetes/client-node/dist/top.js:61:92
    at Array.filter (<anonymous>)
    at Object.topNodes (/home/user/tmp/k8s-client-node/node_modules/@kubernetes/client-node/dist/top.js:59:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async main (/home/user/tmp/k8s-client-node/main.js:9:21)

** Client Version **
e.g. 0.20.0

** Server Version **
e.g. v1.24.9 (also tested in 1.26)

To Reproduce

npm init --yes
npm install @kubernetes/client-node@0.20.0
node <<EOF
const k8s = require('@kubernetes/client-node');

const kc = new k8s.KubeConfig();
kc.loadFromDefault();

const k8sApi = kc.makeApiClient(k8s.CoreV1Api);

const main = async () => {
        console.log(await k8s.topNodes(k8sApi))
};

main();
EOF

Expected behavior

the topNodes promise should resovle and return a list of resources

Environment (please complete the following information):

  • OS: Linux
  • NodeJS Version: v16.17.0

Additional context

The issue was introduced after 0.18.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions