Browse Source

YARN-9816. EntityGroupFSTimelineStore#scanActiveLogs fails when undesired files are present under /ats/active. Contribued by Prabhu Joseph.

Abhishek Modi 5 years ago
parent
commit
44850f6784

+ 6 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/EntityGroupFSTimelineStore.java

@@ -376,7 +376,12 @@ public class EntityGroupFSTimelineStore extends CompositeService
         AppLogs logs = getAndSetActiveLog(appId, stat.getPath());
         executor.execute(new ActiveLogParser(logs));
       } else {
-        logsToScanCount += scanActiveLogs(stat.getPath());
+        if (stat.isDirectory()) {
+          logsToScanCount += scanActiveLogs(stat.getPath());
+        } else {
+          LOG.warn("Ignoring unexpected file in active directory {}",
+              stat.getPath());
+        }
       }
     }
     return logsToScanCount;

+ 17 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestEntityGroupFSTimelineStore.java

@@ -510,6 +510,23 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
     }
   }
 
+  @Test
+  public void testScanActiveLogsWithInvalidFile() throws Exception {
+    Path invalidFile = new Path(testActiveDirPath, "invalidfile");
+    try {
+      if (!fs.exists(invalidFile)) {
+        fs.createNewFile(invalidFile);
+      }
+      store.scanActiveLogs();
+    } catch (StackOverflowError error) {
+      Assert.fail("EntityLogScanner crashed with StackOverflowError");
+    } finally {
+      if (fs.exists(invalidFile)) {
+        fs.delete(invalidFile, false);
+      }
+    }
+  }
+
   @Test
   public void testScanActiveLogsAndMoveToDonePluginRead() throws Exception {
     EntityGroupFSTimelineStore store = null;