From 38ea1419f60d2b8176dba4931748f1f0e52ca84e Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Mon, 1 Dec 2014 22:29:05 +0000 Subject: [PATCH] YARN-2905. AggregatedLogsBlock page can infinitely loop if the aggregated log file is corrupted. Contributed by Varun Saxena (cherry picked from commit 0f9528b99addbb0fd9a19d84db22a8c8e934b05f) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../yarn/logaggregation/AggregatedLogFormat.java | 4 ++++ .../hadoop/yarn/webapp/log/AggregatedLogsBlock.java | 10 ++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index f9ec5eda4b5..a570a0ffde4 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -128,6 +128,9 @@ Release 2.7.0 - UNRELEASED YARN-2906. CapacitySchedulerPage shows HTML tags for a queue's Active Users. (Jason Lowe via jianhe) + YARN-2905. AggregatedLogsBlock page can infinitely loop if the aggregated + log file is corrupted (Varun Saxena via jlowe) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java index a434ef59a6d..7eebcb334ff 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java @@ -801,6 +801,10 @@ public class AggregatedLogFormat { return currentLogData.skip(n); } + public int read() throws IOException { + return currentLogData.read(); + } + public int read(byte[] buf, int off, int len) throws IOException { return currentLogData.read(buf, off, len); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/log/AggregatedLogsBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/log/AggregatedLogsBlock.java index 3e9f7a24758..620d097bdb5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/log/AggregatedLogsBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/log/AggregatedLogsBlock.java @@ -231,8 +231,14 @@ public class AggregatedLogsBlock extends HtmlBlock { long totalSkipped = 0; while (totalSkipped < start) { long ret = logReader.skip(start - totalSkipped); - if (ret < 0) { - throw new IOException( "Premature EOF from container log"); + if (ret == 0) { + //Read one byte + int nextByte = logReader.read(); + // Check if we have reached EOF + if (nextByte == -1) { + throw new IOException( "Premature EOF from container log"); + } + ret = 1; } totalSkipped += ret; }