From ca7d0fda4f7feac8ecb85f706c92a8989fb50523 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 7476d759edc..77020044a17 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 @@ -510,9 +510,7 @@ public class NMWebServices { } } - 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 b1b15189de1..aa5efbe0801 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 fffae30ab30..966e408d2cf 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 52f0c86c8e8..919e54df545 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 f520c46b9b4..1f312722072 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 55840ade343..0464cc8db50 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