svn merge -c 1588546 FIXES: YARN-1940. deleteAsUser() terminates early without deleting more files on error. Contributed by Rushabh S Shah

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1588549 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason Darrell Lowe 2014-04-18 19:36:18 +00:00
parent 8d12e9bf81
commit ccec38b801
2 changed files with 21 additions and 2 deletions

View File

@ -53,6 +53,9 @@ Release 2.5.0 - UNRELEASED
YARN-1784. TestContainerAllocation assumes CapacityScheduler. YARN-1784. TestContainerAllocation assumes CapacityScheduler.
(Robert Kanter via kasha) (Robert Kanter via kasha)
YARN-1940. deleteAsUser() terminates early without deleting more files on
error (Rushabh S Shah via jlowe)
Release 2.4.1 - UNRELEASED Release 2.4.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1082,6 +1082,7 @@ static int delete_path(const char *full_path,
FTS* tree = fts_open(paths, FTS_PHYSICAL | FTS_XDEV, NULL); FTS* tree = fts_open(paths, FTS_PHYSICAL | FTS_XDEV, NULL);
FTSENT* entry = NULL; FTSENT* entry = NULL;
int ret = 0; int ret = 0;
int ret_errno = 0;
if (tree == NULL) { if (tree == NULL) {
fprintf(LOGFILE, fprintf(LOGFILE,
@ -1099,8 +1100,14 @@ static int delete_path(const char *full_path,
if (rmdir(entry->fts_accpath) != 0) { if (rmdir(entry->fts_accpath) != 0) {
fprintf(LOGFILE, "Couldn't delete directory %s - %s\n", fprintf(LOGFILE, "Couldn't delete directory %s - %s\n",
entry->fts_path, strerror(errno)); entry->fts_path, strerror(errno));
if (errno == EROFS) {
exit_code = -1; exit_code = -1;
} }
// record the first errno
if (errno != ENOENT && ret_errno == 0) {
ret_errno = errno;
}
}
} }
break; break;
@ -1111,8 +1118,14 @@ static int delete_path(const char *full_path,
if (unlink(entry->fts_accpath) != 0) { if (unlink(entry->fts_accpath) != 0) {
fprintf(LOGFILE, "Couldn't delete file %s - %s\n", entry->fts_path, fprintf(LOGFILE, "Couldn't delete file %s - %s\n", entry->fts_path,
strerror(errno)); strerror(errno));
if (errno == EROFS) {
exit_code = -1; exit_code = -1;
} }
// record the first errno
if (errno != ENOENT && ret_errno == 0) {
ret_errno = errno;
}
}
break; break;
case FTS_DNR: // Unreadable directory case FTS_DNR: // Unreadable directory
@ -1154,6 +1167,9 @@ static int delete_path(const char *full_path,
} }
} }
ret = fts_close(tree); ret = fts_close(tree);
if (ret_errno != 0) {
exit_code = -1;
}
if (exit_code == 0 && ret != 0) { if (exit_code == 0 && ret != 0) {
fprintf(LOGFILE, "Error in fts_close while deleting %s\n", full_path); fprintf(LOGFILE, "Error in fts_close while deleting %s\n", full_path);
exit_code = -1; exit_code = -1;