[Dashboard] Fix NPE when there is no GPU on the node (#21650)

There is an NPE bug that causes browser crash when no GPU on the node.
We can add a condition to fix it.
This commit is contained in:
Yao Yuan 2022-01-19 00:12:49 +08:00 committed by GitHub
parent 12b087acb8
commit 422d20e945
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -208,7 +208,9 @@ const NodeInfo: React.FC<{}> = () => {
// Show GPU features only if there is at least one GPU in cluster.
const showGPUs =
nodes.map((n) => n.gpus).filter((gpus) => gpus.length !== 0).length !== 0;
nodes
.map((n) => n.gpus)
.filter((gpus) => gpus !== undefined && gpus.length !== 0).length !== 0;
// Don't show disk on Kubernetes. K8s node disk usage should be monitored
// elsewhere.