adoroszlai commented on code in PR #5790:
URL: https://github.com/apache/ozone/pull/5790#discussion_r1427923416


##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/CloseSubcommand.java:
##########
@@ -53,7 +51,6 @@ public class CloseSubcommand extends ScmSubcommand {
 
   @Override
   public void execute(ScmClient scmClient) throws IOException {
-    checkContainerExists(scmClient, containerId);
     try {
       scmClient.closeContainer(containerId);
     } catch (IOException ioe) {

Review Comment:
   The unexpected stack trace is caused by the special logic in the `catch` 
block here, added by HDDS-9635.  It works OK on current `master` because 
`checkContainerExists` is outside of the `try-catch`.
   
   We can fix it simply by removing all of the custom logic, and relying on 
`GenericCli` to handle the error:
   
   
https://github.com/apache/ozone/blob/493c90066feefbe606eba4809e964801b600042e/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java#L103-L112
   
   which only prints the first line of the exception.
   
   So `execute` becomes:
   
   ```java
     public void execute(ScmClient scmClient) throws IOException {
       scmClient.closeContainer(containerId);
     }
   ```
   
   We can also remove `spec` and `LOG`, and unused imports.
   
   With this change, output for closing/closed/unknown containers becomes:
   
   ```
   $ ozone admin container close 1
   Container 1 is in closing state
   
   $ ozone admin container close 1
   Container 1 already closed
   
   $ ozone admin container close 2
   Container with id #2 not found.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to