瀏覽代碼

YARN-6056. Yarn NM using LCE shows a failure when trying to delete a non-existing dir (Wilfred Spiegelenburg via Varun Saxena)

Varun Saxena 8 年之前
父節點
當前提交
c73c894018

+ 10 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c

@@ -1354,6 +1354,16 @@ int delete_as_user(const char *user,
   }
   // do the delete
   for(ptr = (char**)baseDirs; *ptr != NULL; ++ptr) {
+    struct stat sb;
+    if (stat(*ptr, &sb) != 0) {
+      if (errno == ENOENT) {
+        // Ignore missing dir. Continue deleting other directories.
+        continue;
+      } else {
+        fprintf(LOGFILE, "Could not stat %s - %s\n", *ptr, strerror(errno));
+        return -1;
+      }
+    }
     char* full_path = concatenate("%s/%s", "user subdir", 2,
                               *ptr, subdir);
     if (full_path == NULL) {

+ 12 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c

@@ -383,6 +383,18 @@ void test_delete_user() {
     exit(1);
   }
   char buffer[100000];
+
+  sprintf(buffer, "%s", app_dir);
+  char missing_dir[20];
+  strcpy(missing_dir, "/some/missing/dir");
+  char * dirs_with_missing[] = {missing_dir, buffer, 0};
+  int ret = delete_as_user(yarn_username, "" , dirs_with_missing);
+  printf("%d" , ret);
+  if (access(buffer, R_OK) == 0) {
+    printf("FAIL: directory not deleted\n");
+    exit(1);
+  }
+
   sprintf(buffer, "%s/local-1/usercache/%s", TEST_ROOT, yarn_username);
   if (access(buffer, R_OK) != 0) {
     printf("FAIL: directory missing before test\n");