Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDFS-15515: mkdirs on fallback should throw IOE out instead of suppressing and returning false #2205

Merged
merged 2 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ public FsStatus getStatus(Path p) throws IOException {

@Override
public boolean mkdirs(Path dir, FsPermission permission)
throws AccessControlException, FileAlreadyExistsException {
throws IOException {
if (theInternalDir.isRoot() && dir == null) {
throw new FileAlreadyExistsException("/ already exits");
}
Expand Down Expand Up @@ -1451,16 +1451,15 @@ public boolean mkdirs(Path dir, FsPermission permission)
.append(linkedFallbackFs.getUri());
LOG.debug(msg.toString(), e);
}
return false;
throw e;
}
}

throw readOnlyMountTable("mkdirs", dir);
}

@Override
public boolean mkdirs(Path dir)
throws AccessControlException, FileAlreadyExistsException {
public boolean mkdirs(Path dir) throws IOException {
return mkdirs(dir, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.fs.viewfs;

import static org.apache.hadoop.test.LambdaTestUtils.intercept;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -759,7 +760,9 @@ public void testMkdirsShouldReturnFalseWhenFallbackFSNotAvailable()
cluster.shutdownNameNodes(); // Stopping fallback server
// /user1/test1 does not exist in mount internal dir tree, it would
// attempt to create in fallback.
assertFalse(vfs.mkdirs(nextLevelToInternalDir));
intercept(IOException.class, () -> {
vfs.mkdirs(nextLevelToInternalDir);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use LambdaTestUtils.intercept()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

});
cluster.restartNameNodes();
// should return true succeed when fallback fs is back to normal.
assertTrue(vfs.mkdirs(nextLevelToInternalDir));
Expand Down