Skip to content

Commit 0bc696c

Browse files
committed
HDFS-16957. RBF: Exit status of dfsrouteradmin -rm should be non-zero for unsuccessful attempt
1 parent 759ddeb commit 0bc696c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ public int run(String[] argv) throws Exception {
369369
try {
370370
if (removeMount(argv[i])) {
371371
System.out.println("Successfully removed mount point " + argv[i]);
372+
} else {
373+
exitCode = -1;
374+
System.err.println("Failed to remove mount point " + argv[i]);
372375
}
373376
} catch (IOException e) {
374377
exitCode = -1;

hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,13 @@ public void testRemoveMountTable() throws Exception {
433433
// remove an invalid mount table
434434
String invalidPath = "/invalid";
435435
System.setOut(new PrintStream(out));
436+
System.setErr(new PrintStream(err));
436437
argv = new String[] {"-rm", invalidPath};
437-
assertEquals(0, ToolRunner.run(admin, argv));
438+
assertEquals(-1, ToolRunner.run(admin, argv));
438439
assertTrue(out.toString().contains(
439440
"Cannot remove mount point " + invalidPath));
441+
assertEquals("DFS Router Admin should report error for failure to remove mount point",
442+
"Failed to remove mount point " + invalidPath + "\n", err.toString());
440443
}
441444

442445
@Test

0 commit comments

Comments
 (0)