You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by sw...@apache.org on 2022/06/17 18:08:37 UTC

[ozone] branch master updated: HDDS-6882. Correct exit code for invalid arguments passed to command-line tools. (#3517)

This is an automated email from the ASF dual-hosted git repository.

swagle pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new d86d6a81bc HDDS-6882. Correct exit code for invalid arguments passed to command-line tools. (#3517)
d86d6a81bc is described below

commit d86d6a81bc2e59c6be606c8e4c016c0b3844409f
Author: Duong Nguyen <du...@gmail.com>
AuthorDate: Fri Jun 17 11:08:30 2022 -0700

    HDDS-6882. Correct exit code for invalid arguments passed to command-line tools. (#3517)
---
 .../org/apache/hadoop/hdds/cli/GenericCli.java     | 24 ++++++----
 .../server/TestStorageContainerManagerStarter.java | 53 +++++++++-------------
 .../org/apache/hadoop/hdds/cli/OzoneAdmin.java     |  9 ++--
 .../src/main/smoketest/basic/ozone-shell-lib.robot | 20 +++++++-
 .../src/main/smoketest/basic/ozone-shell.robot     |  3 ++
 .../org/apache/hadoop/ozone/OzoneChaosCluster.java |  5 --
 .../hadoop/ozone/om/TestOzoneManagerStarter.java   | 50 +++++++-------------
 .../java/org/apache/hadoop/ozone/freon/Freon.java  |  4 +-
 .../hadoop/ozone/segmentparser/RatisLogParser.java |  5 --
 .../org/apache/hadoop/ozone/shell/OzoneShell.java  |  9 ++--
 .../org/apache/hadoop/ozone/shell/s3/S3Shell.java  |  9 ++--
 .../hadoop/ozone/shell/tenant/TenantShell.java     |  9 ++--
 12 files changed, 89 insertions(+), 111 deletions(-)

diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java
index 2c7f3d5db6..4c5f3fdc87 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java
@@ -28,16 +28,17 @@ import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import com.google.common.annotations.VisibleForTesting;
 import picocli.CommandLine;
 import picocli.CommandLine.Command;
-import picocli.CommandLine.ExecutionException;
+import picocli.CommandLine.ExitCode;
 import picocli.CommandLine.Model.CommandSpec;
 import picocli.CommandLine.Option;
-import picocli.CommandLine.RunLast;
 
 /**
  * This is a generic parent class for all the ozone related cli tools.
  */
 public class GenericCli implements Callable<Void>, GenericParentCommand {
 
+  public static final int EXECUTION_ERROR_EXIT_CODE = -1;
+
   @Option(names = {"--verbose"},
       description = "More verbose output. Show the stack trace of the errors.")
   private boolean verbose;
@@ -52,6 +53,10 @@ public class GenericCli implements Callable<Void>, GenericParentCommand {
 
   public GenericCli() {
     cmd = new CommandLine(this);
+    cmd.setExecutionExceptionHandler((ex, commandLine, parseResult) -> {
+      printError(ex);
+      return EXECUTION_ERROR_EXIT_CODE;
+    });
   }
 
   public GenericCli(Class<?> type) {
@@ -79,21 +84,20 @@ public class GenericCli implements Callable<Void>, GenericParentCommand {
   public static void missingSubcommand(CommandSpec spec) {
     System.err.println("Incomplete command");
     spec.commandLine().usage(System.err);
-    System.exit(-1);
+    System.exit(EXECUTION_ERROR_EXIT_CODE);
   }
 
   public void run(String[] argv) {
-    try {
-      execute(argv);
-    } catch (ExecutionException ex) {
-      printError(ex.getCause() == null ? ex : ex.getCause());
-      System.exit(-1);
+    int exitCode = execute(argv);
+
+    if (exitCode != ExitCode.OK) {
+      System.exit(exitCode);
     }
   }
 
   @VisibleForTesting
-  public void execute(String[] argv) {
-    cmd.parseWithHandler(new RunLast(), argv);
+  public int execute(String[] argv) {
+    return cmd.execute(argv);
   }
 
   protected void printError(Throwable error) {
diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestStorageContainerManagerStarter.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestStorageContainerManagerStarter.java
index e138c4e448..a7a539516b 100644
--- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestStorageContainerManagerStarter.java
+++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestStorageContainerManagerStarter.java
@@ -17,10 +17,13 @@
  */
 package org.apache.hadoop.hdds.scm.server;
 
+import org.apache.hadoop.hdds.cli.GenericCli;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import picocli.CommandLine.ExitCode;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
@@ -32,7 +35,6 @@ import java.util.regex.Pattern;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
@@ -64,102 +66,91 @@ public class TestStorageContainerManagerStarter {
 
   @Test
   public void testCallsStartWhenServerStarted() throws Exception {
-    executeCommand();
+    assertEquals(ExitCode.OK, executeCommand());
     assertTrue(mock.startCalled);
   }
 
   @Test
   public void testExceptionThrownWhenStartFails() throws Exception {
     mock.throwOnStart = true;
-    try {
-      executeCommand();
-      fail("Exception show have been thrown");
-    } catch (Exception e) {
-      assertTrue(true);
-    }
+    assertEquals(GenericCli.EXECUTION_ERROR_EXIT_CODE, executeCommand());
   }
 
   @Test
   public void testStartNotCalledWithInvalidParam() throws Exception {
-    executeCommand("--invalid");
+    assertEquals(ExitCode.USAGE, executeCommand("--invalid"));
     assertFalse(mock.startCalled);
   }
 
   @Test
   public void testPassingInitSwitchCallsInit() {
-    executeCommand("--init");
+    assertEquals(ExitCode.OK, executeCommand("--init"));
     assertTrue(mock.initCalled);
   }
 
   @Test
   public void testPassingBootStrapSwitchCallsBootStrap() {
-    executeCommand("--bootstrap");
+    assertEquals(ExitCode.OK, executeCommand("--bootstrap"));
     assertTrue(mock.bootStrapCalled);
   }
 
   @Test
   public void testInitSwitchAcceptsClusterIdSSwitch() {
-    executeCommand("--init", "--clusterid=abcdefg");
+    assertEquals(ExitCode.OK, executeCommand("--init", "--clusterid=abcdefg"));
     assertEquals("abcdefg", mock.clusterId);
   }
 
   @Test
   public void testInitSwitchWithInvalidParamDoesNotRun() {
-    executeCommand("--init", "--clusterid=abcdefg", "--invalid");
+    assertEquals(ExitCode.USAGE,
+            executeCommand("--init", "--clusterid=abcdefg", "--invalid"));
     assertFalse(mock.initCalled);
   }
 
   @Test
   public void testBootStrapSwitchWithInvalidParamDoesNotRun() {
-    executeCommand("--bootstrap", "--clusterid=abcdefg", "--invalid");
+    assertEquals(ExitCode.USAGE,
+            executeCommand("--bootstrap", "--clusterid=abcdefg", "--invalid"));
     assertFalse(mock.bootStrapCalled);
   }
 
   @Test
   public void testUnSuccessfulInitThrowsException() {
     mock.throwOnInit = true;
-    try {
-      executeCommand("--init");
-      fail("Exception show have been thrown");
-    } catch (Exception e) {
-      assertTrue(true);
-    }
+    assertEquals(GenericCli.EXECUTION_ERROR_EXIT_CODE,
+            executeCommand("--init"));
   }
 
   @Test
   public void testUnSuccessfulBootStrapThrowsException() {
     mock.throwOnBootstrap = true;
-    try {
-      executeCommand("--bootstrap");
-      fail("Exception show have been thrown");
-    } catch (Exception e) {
-      assertTrue(true);
-    }
+    assertEquals(GenericCli.EXECUTION_ERROR_EXIT_CODE,
+            executeCommand("--bootstrap"));
   }
 
   @Test
   public void testGenClusterIdRunsGenerate() {
-    executeCommand("--genclusterid");
+    assertEquals(ExitCode.OK, executeCommand("--genclusterid"));
     assertTrue(mock.generateCalled);
   }
 
   @Test
   public void testGenClusterIdWithInvalidParamDoesNotRun() {
-    executeCommand("--genclusterid", "--invalid");
+    assertEquals(ExitCode.USAGE, executeCommand("--genclusterid", "--invalid"));
     assertFalse(mock.generateCalled);
   }
 
   @Test
   public void testUsagePrintedOnInvalidInput()
       throws UnsupportedEncodingException {
-    executeCommand("--invalid");
+    assertEquals(ExitCode.USAGE, executeCommand("--invalid"));
     Pattern p = Pattern.compile("^Unknown option:.*--invalid.*\nUsage");
     Matcher m = p.matcher(errContent.toString(DEFAULT_ENCODING));
     assertTrue(m.find());
   }
 
-  private void executeCommand(String... args) {
-    new StorageContainerManagerStarter(mock).execute(args);
+  private int executeCommand(String... args) {
+    return new StorageContainerManagerStarter(mock).execute(args);
   }
 
   static class MockSCMStarter implements SCMStarterInterface {
diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/OzoneAdmin.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/OzoneAdmin.java
index 8ba56c1b45..2b171b2d5f 100644
--- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/OzoneAdmin.java
+++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/OzoneAdmin.java
@@ -87,12 +87,9 @@ public class OzoneAdmin extends GenericCli {
   }
 
   @Override
-  public void execute(String[] argv) {
+  public int execute(String[] argv) {
     TracingUtil.initTracing("shell", createOzoneConfiguration());
-    TracingUtil.executeInNewSpan("main",
-        (Supplier<Void>) () -> {
-          super.execute(argv);
-          return null;
-        });
+    return TracingUtil.executeInNewSpan("main",
+        (Supplier<Integer>) () -> super.execute(argv));
   }
 }
diff --git a/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell-lib.robot b/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell-lib.robot
index 56f100ef87..79a0699d05 100644
--- a/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell-lib.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell-lib.robot
@@ -30,7 +30,7 @@ Generate prefix
 
 Test ozone shell
     [arguments]     ${protocol}         ${server}       ${volume}
-    ${result} =     Execute And Ignore Error    ozone sh volume info ${protocol}${server}/${volume}
+    ${result} =     Execute and checkrc    ozone sh volume info ${protocol}${server}/${volume}      255
                     Should contain      ${result}       VOLUME_NOT_FOUND
     ${result} =     Execute             ozone sh volume create ${protocol}${server}/${volume} --space-quota 100TB --namespace-quota 100
                     Should not contain  ${result}       Failed
@@ -86,6 +86,24 @@ Test ozone shell
                     Execute             ozone sh bucket delete ${protocol}${server}/${volume}/bb1
                     Execute             ozone sh volume delete ${protocol}${server}/${volume}
 
+Test ozone shell errors
+    [arguments]     ${protocol}         ${server}       ${volume}
+    ${result} =     Execute and checkrc    ozone sh volume create ${protocol}${server}/${volume} --space-quota invalid      255
+                    Should contain      ${result}       Invalid
+                    Execute and checkrc    ozone sh volume create ${protocol}${server}/${volume}                            0
+    ${result} =     Execute and checkrc    ozone sh bucket create ${protocol}${server}/${volume}/bucket_1                   255
+                    Should contain      ${result}       INVALID_BUCKET_NAME
+    ${result} =     Execute and checkrc    ozone sh bucket create ${protocol}${server}/${volume}/bucket1 --layout Invalid   2
+                    Should contain      ${result}       Usage
+                    Execute and checkrc    ozone sh bucket create ${protocol}${server}/${volume}/bucket1                    0
+    ${result} =     Execute and checkrc    ozone sh key info ${protocol}${server}/${volume}/bucket1/non-existing           255
+                    Should contain      ${result}       KEY_NOT_FOUND
+    ${result} =     Execute and checkrc    ozone sh key put ${protocol}${server}/${volume}/bucket1/key1 unexisting --type invalid    2
+                    Execute and checkrc    ozone sh bucket delete ${protocol}${server}/${volume}/bucket1                    0
+                    Execute and checkrc    ozone sh volume delete ${protocol}${server}/${volume}                            0
+
+
+
 Test Volume Acls
     [arguments]     ${protocol}         ${server}       ${volume}
     Execute         ozone sh volume create ${protocol}${server}/${volume}
diff --git a/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell.robot b/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell.robot
index cfcd5d626a..3053cd909c 100644
--- a/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell.robot
@@ -26,6 +26,9 @@ Suite Setup         Generate prefix
 RpcClient with port
    Test ozone shell       o3://            om:9862     ${prefix}-with-host
 
+RpcClient with execution errors
+   Test ozone shell errors    o3://        om:9862     ${prefix}-with-errors
+
 RpcClient volume acls
    Test Volume Acls       o3://            om:9862     ${prefix}-acls
 
diff --git a/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/OzoneChaosCluster.java b/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/OzoneChaosCluster.java
index 6723e46d56..e8ced03112 100644
--- a/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/OzoneChaosCluster.java
+++ b/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/OzoneChaosCluster.java
@@ -37,11 +37,6 @@ import picocli.CommandLine;
     versionProvider = HddsVersionProvider.class,
     mixinStandardHelpOptions = true)
 public class OzoneChaosCluster extends GenericCli {
-  @Override
-  public void execute(String[] argv) {
-    super.execute(argv);
-  }
-
   public static void main(String[] args) {
     new OzoneChaosCluster().run(args);
   }
diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerStarter.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerStarter.java
index 19183f3493..754134d869 100644
--- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerStarter.java
+++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerStarter.java
@@ -22,6 +22,7 @@ import org.apache.hadoop.security.authentication.client.AuthenticationException;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
@@ -30,9 +31,12 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.hadoop.hdds.cli.GenericCli.EXECUTION_ERROR_EXIT_CODE;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static picocli.CommandLine.ExitCode.OK;
+import static picocli.CommandLine.ExitCode.USAGE;
 
 /**
  * This class is used to test the CLI provided by OzoneManagerStarter, which is
@@ -65,89 +69,69 @@ public class TestOzoneManagerStarter {
 
   @Test
   public void testCallsStartWhenServerStarted() throws Exception {
-    executeCommand();
+    assertEquals(OK, executeCommand());
     assertTrue(mock.startCalled);
   }
 
   @Test
   public void testExceptionThrownWhenStartFails() throws Exception {
     mock.throwOnStart = true;
-    try {
-      executeCommand();
-      fail("Exception should have been thrown");
-    } catch (Exception e) {
-      assertTrue(true);
-    }
+    assertEquals(EXECUTION_ERROR_EXIT_CODE, executeCommand());
   }
 
   @Test
   public void testStartNotCalledWithInvalidParam() throws Exception {
-    executeCommand("--invalid");
+    assertEquals(USAGE, executeCommand("--invalid"));
     assertFalse(mock.startCalled);
   }
 
   @Test
   public void testPassingInitSwitchCallsInit() {
-    executeCommand("--init");
+    assertEquals(OK, executeCommand("--init"));
     assertTrue(mock.initCalled);
   }
 
   @Test
   public void testInitSwitchWithInvalidParamDoesNotRun() {
-    executeCommand("--init", "--invalid");
+    assertEquals(USAGE, executeCommand("--init", "--invalid"));
     assertFalse(mock.initCalled);
   }
 
   @Test
   public void testUnSuccessfulInitThrowsException() {
     mock.throwOnInit = true;
-    try {
-      executeCommand("--init");
-      fail("Exception show have been thrown");
-    } catch (Exception e) {
-      assertTrue(true);
-    }
+    assertEquals(EXECUTION_ERROR_EXIT_CODE, executeCommand("--init"));
   }
 
   @Test
   public void testInitThatReturnsFalseThrowsException() {
     mock.initStatus = false;
-    try {
-      executeCommand("--init");
-      fail("Exception show have been thrown");
-    } catch (Exception e) {
-      assertTrue(true);
-    }
+    assertEquals(EXECUTION_ERROR_EXIT_CODE, executeCommand("--init"));
   }
 
   @Test
   public void testCallsStartAndCancelPrepareWithUpgradeFlag() {
-    executeCommand("--upgrade");
+    assertEquals(OK, executeCommand("--upgrade"));
     assertTrue(mock.startAndCancelPrepareCalled);
   }
 
   @Test
   public void testUnsuccessfulUpgradeThrowsException() {
     mock.throwOnStartAndCancelPrepare = true;
-    try {
-      executeCommand("--upgrade");
-      fail("Exception show have been thrown");
-    } catch (Exception e) {
-      assertTrue(true);
-    }
+    assertEquals(EXECUTION_ERROR_EXIT_CODE, executeCommand("--upgrade"));
   }
 
   @Test
   public void testUsagePrintedOnInvalidInput()
       throws UnsupportedEncodingException {
-    executeCommand("--invalid");
+    assertEquals(USAGE, executeCommand("--invalid"));
     Pattern p = Pattern.compile("^Unknown option:.*--invalid.*\nUsage");
     Matcher m = p.matcher(errContent.toString(DEFAULT_ENCODING));
     assertTrue(m.find());
   }
 
-  private void executeCommand(String... args) {
-    new OzoneManagerStarter(mock).execute(args);
+  private int executeCommand(String... args) {
+    return new OzoneManagerStarter(mock).execute(args);
   }
 
   static class MockOMStarter implements OMStarterInterface {
diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/Freon.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/Freon.java
index ab04d6d968..0f70659c16 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/Freon.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/Freon.java
@@ -87,11 +87,11 @@ public class Freon extends GenericCli {
   private OzoneConfiguration conf;
 
   @Override
-  public void execute(String[] argv) {
+  public int execute(String[] argv) {
     conf = createOzoneConfiguration();
     HddsServerUtil.initializeMetrics(conf, "ozone-freon");
     TracingUtil.initTracing("freon", conf);
-    super.execute(argv);
+    return super.execute(argv);
   }
 
   public void stopHttpServer() {
diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/segmentparser/RatisLogParser.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/segmentparser/RatisLogParser.java
index 880fd75e57..d41ee2dec1 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/segmentparser/RatisLogParser.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/segmentparser/RatisLogParser.java
@@ -42,11 +42,6 @@ import picocli.CommandLine;
 @MetaInfServices(SubcommandWithParent.class)
 public class RatisLogParser extends GenericCli implements SubcommandWithParent {
 
-  @Override
-  public void execute(String[] argv) {
-    super.execute(argv);
-  }
-
   public static void main(String[] args) {
     new RatisLogParser().run(args);
   }
diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java
index ab1441c3f8..353960339d 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java
@@ -48,13 +48,10 @@ public class OzoneShell extends Shell {
   }
 
   @Override
-  public void execute(String[] argv) {
+  public int execute(String[] argv) {
     TracingUtil.initTracing("shell", createOzoneConfiguration());
-    TracingUtil.executeInNewSpan("main",
-        (Supplier<Void>) () -> {
-          super.execute(argv);
-          return null;
-        });
+    return TracingUtil.executeInNewSpan("main",
+        (Supplier<Integer>) () -> super.execute(argv));
   }
 
 }
diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java
index 13f59c4f6c..359f92d774 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java
@@ -37,13 +37,10 @@ import picocli.CommandLine.Command;
 public class S3Shell extends Shell {
 
   @Override
-  public void execute(String[] argv) {
+  public int execute(String[] argv) {
     TracingUtil.initTracing("s3shell", createOzoneConfiguration());
-    TracingUtil.executeInNewSpan("s3shell",
-        (Supplier<Void>) () -> {
-          super.execute(argv);
-          return null;
-        });
+    return TracingUtil.executeInNewSpan("s3shell",
+        (Supplier<Integer>) () -> super.execute(argv));
   }
 
   /**
diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java
index 42c60fbd79..d06a330dd2 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java
@@ -38,13 +38,10 @@ import java.util.function.Supplier;
 public class TenantShell extends Shell {
 
   @Override
-  public void execute(String[] argv) {
+  public int execute(String[] argv) {
     TracingUtil.initTracing("tenant-shell", createOzoneConfiguration());
-    TracingUtil.executeInNewSpan("tenant-shell",
-        (Supplier<Void>) () -> {
-          super.execute(argv);
-          return null;
-        });
+    return TracingUtil.executeInNewSpan("tenant-shell",
+        (Supplier<Integer>) () -> super.execute(argv));
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org