diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java index 67c3bc7..8cc5ed3 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java @@ -177,9 +177,10 @@ private static boolean checkPublicPermsForAll(FileSystem fs, /** * Returns true if all ancestors of the specified path have the 'execute' * permission set for all users (i.e. that other users can traverse - * the directory heirarchy to the given path) + * the directory hierarchy to the given path) */ - private static boolean ancestorsHaveExecutePermissions(FileSystem fs, + @VisibleForTesting + static boolean ancestorsHaveExecutePermissions(FileSystem fs, Path path, LoadingCache> statCache) throws IOException { Path current = path; diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java index 4d0c8da..405ddd5 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java @@ -21,6 +21,7 @@ import static org.apache.hadoop.fs.CreateFlag.CREATE; import static org.apache.hadoop.fs.CreateFlag.OVERWRITE; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -66,6 +67,7 @@ import org.apache.hadoop.fs.LocalDirAllocator; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; +import org.apache.hadoop.util.Shell; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LocalResourceType; @@ -358,9 +360,21 @@ public Boolean call() throws IOException { ExecutorService exec = Executors.newFixedThreadPool(fileCount); try { List> futures = exec.invokeAll(tasks); - // files should be public - for (Future future: futures) { - assertTrue(future.get()); + FileSystem fs = basedir.getFileSystem(conf); + if (Shell.WINDOWS || + FSDownload.ancestorsHaveExecutePermissions(fs, basedir, null)) { + // files should be public + for (Future future: futures) { + assertTrue(future.get()); + } + } else { + // if the files are non-public, skip the test + LOG.warn("Some ancestors of the base directory: " + basedir.toString() + + " doesn't have execute permission for all users." + + " Skip the test."); + for (Future future : futures) { + assertFalse(future.get()); + } } // for each path exactly one file status call should be made for (AtomicInteger count: counts.values()) {