diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/SecureModeLocalUserAllocator.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/SecureModeLocalUserAllocator.java index 1ff01424508..3de16e2db50 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/SecureModeLocalUserAllocator.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/SecureModeLocalUserAllocator.java @@ -316,27 +316,35 @@ public class SecureModeLocalUserAllocator { String localUser = appUserToLocalUser.remove(appUser).localUser; allocated.set(localUserInfo.localUserIndex, false); if (delService != null) { - // check if node manager usercache//appcache folder exists + // check and delete these node manager folders, which will cause permission issues later: + // usercache//appcache + // usercache//filecche for (String localDir : nmLocalDirs) { Path usersDir = new Path(localDir, ContainerLocalizer.USERCACHE); Path userDir = new Path(usersDir, appUser); Path userAppCacheDir = new Path(userDir, ContainerLocalizer.APPCACHE); - FileStatus status; - try { - status = lfs.getFileStatus(userAppCacheDir); - } - catch(FileNotFoundException fs) { - status = null; - } - catch(IOException ie) { - String msg = "Could not get file status for local dir " + userDir; - LOG.warn(msg, ie); - throw new YarnRuntimeException(msg, ie); - } - if (status != null) { - FileDeletionTask delTask = new FileDeletionTask(delService, localUser, - userAppCacheDir, null); - delService.delete(delTask); + Path userFileCacheDir = new Path(userDir, ContainerLocalizer.FILECACHE); + ArrayList toDelete = new ArrayList(); + toDelete.add(userAppCacheDir); + toDelete.add(userFileCacheDir); + + for (Path dir : toDelete) { + FileStatus status = null; + try { + status = lfs.getFileStatus(userAppCacheDir); + } + catch(FileNotFoundException fs) { + } + catch(IOException ie) { + String msg = "Could not get file status for local dir " + dir; + LOG.warn(msg, ie); + throw new YarnRuntimeException(msg, ie); + } + if (status != null) { + FileDeletionTask delTask = new FileDeletionTask(delService, localUser, + dir, null); + delService.delete(delTask); + } } } } @@ -344,4 +352,4 @@ public class SecureModeLocalUserAllocator { " for appUser " + appUser); } } -} \ No newline at end of file +}