From c9a54aab6b1ad91b14de934178018d8e7eecd001 Mon Sep 17 00:00:00 2001 From: Wangda Tan Date: Wed, 29 Nov 2017 17:43:37 -0800 Subject: [PATCH] YARN-7573. Gpu Information page could be empty for nodes without GPU. (Sunil G via wangda) Change-Id: I7f614e5a589a09ce4e4286c84b706e05c29abd14 --- .../yarn/server/nodemanager/webapp/NMWebServices.java | 4 +--- .../src/main/webapp/app/models/yarn-rm-node.js | 6 ++++-- .../webapp/app/templates/components/node-menu-panel.hbs | 2 +- .../src/main/webapp/app/templates/yarn-node-apps.hbs | 2 +- .../src/main/webapp/app/templates/yarn-node-containers.hbs | 2 +- .../src/main/webapp/app/templates/yarn-node/yarn-nm-gpu.hbs | 4 ++++ 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java index 937a8cd04e..9157374928 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java @@ -519,9 +519,7 @@ public Object getNMResourceInfo( } } - throw new YarnException( - "Could not get detailed resource information for given resource-name=" - + resourceName); + return new NMResourceInfo(); } private long parseLongParam(String bytes) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-rm-node.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-rm-node.js index da5ba01115..3b2385fcd5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-rm-node.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/models/yarn-rm-node.js @@ -97,7 +97,9 @@ export default DS.Model.extend({ var used = 0; var ri; - var resourceInformations = this.get("usedResource").resourcesInformations; + const usedResource = this.get("usedResource"); + const availableResource = this.get("availableResource"); + var resourceInformations = usedResource ? usedResource.resourcesInformations : []; for (var i = 0; i < resourceInformations.length; i++) { ri = resourceInformations[i]; if (ri.name === "yarn.io/gpu") { @@ -106,7 +108,7 @@ export default DS.Model.extend({ } var available = 0; - resourceInformations = this.get("availableResource").resourcesInformations; + resourceInformations = availableResource ? availableResource.resourcesInformations : []; for (i = 0; i < resourceInformations.length; i++) { ri = resourceInformations[i]; if (ri.name === "yarn.io/gpu") { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/node-menu-panel.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/node-menu-panel.hbs index fffae30ab3..966e408d2c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/node-menu-panel.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/node-menu-panel.hbs @@ -36,7 +36,7 @@ {{#link-to 'yarn-node-containers' nodeId nodeAddr}}List of Containers {{/link-to}} {{/link-to}} - {{#if nmGpuInfo}} + {{#if (and nmGpuInfo nmGpuInfo.info.totalGpuDevices)}} {{#link-to 'yarn-node.yarn-nm-gpu' tagName="li"}} {{#link-to 'yarn-node.yarn-nm-gpu' nodeId nodeAddr }}GPU Information {{/link-to}} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-apps.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-apps.hbs index 52f0c86c8e..919e54df54 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-apps.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-apps.hbs @@ -20,7 +20,7 @@
- {{node-menu-panel path="yarn-node-apps" nodeAddr=model.nodeInfo.addr nodeId=model.nodeInfo.id}} + {{node-menu-panel path="yarn-node-apps" nodeAddr=model.nodeInfo.addr nodeId=model.nodeInfo.id nmGpuInfo=model.nmGpuInfo}} {{#if model.apps}}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-containers.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-containers.hbs index f520c46b9b..1f31272207 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-containers.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-containers.hbs @@ -20,7 +20,7 @@
- {{node-menu-panel path="yarn-node-containers" nodeAddr=model.nodeInfo.addr nodeId=model.nodeInfo.id}} + {{node-menu-panel path="yarn-node-containers" nodeAddr=model.nodeInfo.addr nodeId=model.nodeInfo.id nmGpuInfo=model.nmGpuInfo}} {{#if model.containers}}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node/yarn-nm-gpu.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node/yarn-nm-gpu.hbs index 55840ade34..0464cc8db5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node/yarn-nm-gpu.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node/yarn-nm-gpu.hbs @@ -23,6 +23,7 @@ {{node-menu-panel path="yarn-node" nodeId=model.rmNode.id nodeAddr=model.node.id nmGpuInfo=model.nmGpuInfo}} + {{#if model.nmGpuInfo.info.totalGpuDevices}}
@@ -49,5 +50,8 @@ {{yarn-nm-gpu-info gpu=gpu}} {{/each}}
+ {{else}} +

No GPUs are found on this node.

+ {{/if}}
\ No newline at end of file