Skip to content

Commit beca49d

Browse files
committed
Fix ContainerLocalizer permission bug by also deleting filecache folder
Signed-off-by: Shanyu Zhao <shzhao@microsoft.com>
1 parent 29242a6 commit beca49d

File tree

1 file changed

+26
-18
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager

1 file changed

+26
-18
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/SecureModeLocalUserAllocator.java

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -316,32 +316,40 @@ private void checkAndDeallocateAppUser(String appUser, LocalUserInfo localUserIn
316316
String localUser = appUserToLocalUser.remove(appUser).localUser;
317317
allocated.set(localUserInfo.localUserIndex, false);
318318
if (delService != null) {
319-
// check if node manager usercache/<appUser>/appcache folder exists
319+
// check and delete these node manager folders, which will cause permission issues later:
320+
// usercache/<appUser>/appcache
321+
// usercache/<appUser>/filecche
320322
for (String localDir : nmLocalDirs) {
321323
Path usersDir = new Path(localDir, ContainerLocalizer.USERCACHE);
322324
Path userDir = new Path(usersDir, appUser);
323325
Path userAppCacheDir = new Path(userDir, ContainerLocalizer.APPCACHE);
324-
FileStatus status;
325-
try {
326-
status = lfs.getFileStatus(userAppCacheDir);
327-
}
328-
catch(FileNotFoundException fs) {
329-
status = null;
330-
}
331-
catch(IOException ie) {
332-
String msg = "Could not get file status for local dir " + userDir;
333-
LOG.warn(msg, ie);
334-
throw new YarnRuntimeException(msg, ie);
335-
}
336-
if (status != null) {
337-
FileDeletionTask delTask = new FileDeletionTask(delService, localUser,
338-
userAppCacheDir, null);
339-
delService.delete(delTask);
326+
Path userFileCacheDir = new Path(userDir, ContainerLocalizer.FILECACHE);
327+
ArrayList<Path> toDelete = new ArrayList<Path>();
328+
toDelete.add(userAppCacheDir);
329+
toDelete.add(userFileCacheDir);
330+
331+
for (Path dir : toDelete) {
332+
FileStatus status = null;
333+
try {
334+
status = lfs.getFileStatus(userAppCacheDir);
335+
}
336+
catch(FileNotFoundException fs) {
337+
}
338+
catch(IOException ie) {
339+
String msg = "Could not get file status for local dir " + dir;
340+
LOG.warn(msg, ie);
341+
throw new YarnRuntimeException(msg, ie);
342+
}
343+
if (status != null) {
344+
FileDeletionTask delTask = new FileDeletionTask(delService, localUser,
345+
dir, null);
346+
delService.delete(delTask);
347+
}
340348
}
341349
}
342350
}
343351
LOG.info("Deallocated local user index " + localUserInfo.localUserIndex +
344352
" for appUser " + appUser);
345353
}
346354
}
347-
}
355+
}

0 commit comments

Comments
 (0)