From dabe96a72eea3fa47993b648dd74750cbafbd51b Mon Sep 17 00:00:00 2001 From: Junping Du Date: Tue, 21 Mar 2017 00:28:05 -0700 Subject: [PATCH] YARN-6367. YARN logs CLI needs alway check containerLogsInfo/containerLogInfo before parse the JSON object from NMWebService. Contributed by Xuan Gong. (cherry picked from commit c01d15ab2731b6710c94ff3bfa37d496a87b0c9f) Conflicts: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java --- .../java/org/apache/hadoop/yarn/client/cli/LogsCLI.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java index de0b64bf8ff..661a9703ba2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java @@ -431,6 +431,9 @@ public class LogsCLI extends Configured implements Tool { JSONArray array = new JSONArray(); JSONObject json = response.getEntity(JSONObject.class); + if (!json.has("containerLogsInfo")) { + return logFileInfos; + } Object logsInfoObj = json.get("containerLogsInfo"); if (logsInfoObj instanceof JSONObject) { array.put((JSONObject)logsInfoObj); @@ -444,6 +447,9 @@ public class LogsCLI extends Configured implements Tool { JSONObject log = array.getJSONObject(i); String aggregateType = log.has("logAggregationType") ? log.getString("logAggregationType") : "N/A"; + if (!log.has("containerLogInfo")) { + continue; + } Object ob = log.get("containerLogInfo"); if (ob instanceof JSONArray) { JSONArray obArray = (JSONArray)ob;