Skip to content

Commit 029b8d6

Browse files
wangdatanPierrotws
authored andcommitted
YARN-8629. Container cleanup fails while trying to delete Cgroups. (Suma Shivaprasad via wangda)
Change-Id: I392ef4f8baa84d5d7b1f2e438c560b5426b6d4f2 (cherry picked from commit d4258fc)
1 parent 22d2864 commit 029b8d6

File tree

1 file changed

+16
-10
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources

1 file changed

+16
-10
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/CGroupsHandlerImpl.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -504,23 +504,29 @@ private void logLineFromTasksFile(File cgf) {
504504
private boolean checkAndDeleteCgroup(File cgf) throws InterruptedException {
505505
boolean deleted = false;
506506
// FileInputStream in = null;
507-
try (FileInputStream in = new FileInputStream(cgf + "/tasks")) {
508-
if (in.read() == -1) {
507+
if ( cgf.exists() ) {
508+
try (FileInputStream in = new FileInputStream(cgf + "/tasks")) {
509+
if (in.read() == -1) {
509510
/*
510511
* "tasks" file is empty, sleep a bit more and then try to delete the
511512
* cgroup. Some versions of linux will occasionally panic due to a race
512513
* condition in this area, hence the paranoia.
513514
*/
514-
Thread.sleep(deleteCGroupDelay);
515-
deleted = cgf.delete();
516-
if (!deleted) {
517-
LOG.warn("Failed attempt to delete cgroup: " + cgf);
515+
Thread.sleep(deleteCGroupDelay);
516+
deleted = cgf.delete();
517+
if (!deleted) {
518+
LOG.warn("Failed attempt to delete cgroup: " + cgf);
519+
}
520+
} else{
521+
logLineFromTasksFile(cgf);
518522
}
519-
} else {
520-
logLineFromTasksFile(cgf);
523+
} catch (IOException e) {
524+
LOG.warn("Failed to read cgroup tasks file. ", e);
521525
}
522-
} catch (IOException e) {
523-
LOG.warn("Failed to read cgroup tasks file. ", e);
526+
} else {
527+
LOG.info("Parent Cgroups directory {} does not exist. Skipping "
528+
+ "deletion", cgf.getPath());
529+
deleted = true;
524530
}
525531
return deleted;
526532
}

0 commit comments

Comments
 (0)