[ 
https://issues.apache.org/jira/browse/HDDS-9827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Attila Doroszlai resolved HDDS-9827.
------------------------------------
    Fix Version/s: 1.5.0
       Resolution: Fixed

> Cryptic response when trying to close non-existent container from CLI
> ---------------------------------------------------------------------
>
>                 Key: HDDS-9827
>                 URL: https://issues.apache.org/jira/browse/HDDS-9827
>             Project: Apache Ozone
>          Issue Type: Sub-task
>          Components: Ozone CLI
>            Reporter: Attila Doroszlai
>            Assignee: Tejaskriya Madhan
>            Priority: Minor
>              Labels: good-first-issue, pull-request-available
>             Fix For: 1.5.0
>
>
> Trying to close a non-existent container results in an uninformative response:
> {code}
> $ ozone admin container close 4
> ID #4
> {code}
> Client first checks if container exists, and only attempts to close if it 
> does.
> {code:title=https://github.com/apache/ozone/blob/eb7e8d009e701d1dc7a792deca1b5d6893d051c0/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/CloseSubcommand.java#L45-L46}
>     checkContainerExists(scmClient, containerId);
>     scmClient.closeContainer(containerId);
> {code}
> {code:title=https://github.com/apache/ozone/blob/eb7e8d009e701d1dc7a792deca1b5d6893d051c0/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ContainerCommands.java#L67-L72}
>   public static void checkContainerExists(ScmClient scmClient, long 
> containerId)
>       throws IOException {
>     ContainerInfo container = scmClient.getContainer(containerId);
>     if (container == null) {
>       throw new IllegalArgumentException("No such container " + containerId);
>     }
> {code}
> But {{scmClient.getContainer}} gets {{ContainerNotFoundException}} instead of 
> {{null}} for non-existent container from:
> {code:title=https://github.com/apache/ozone/blob/eb7e8d009e701d1dc7a792deca1b5d6893d051c0/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java#L136-L140}
>   public ContainerInfo getContainer(final ContainerID id)
>       throws ContainerNotFoundException {
>     return Optional.ofNullable(containerStateManager
>         .getContainer(id))
>         .orElseThrow(() -> new ContainerNotFoundException("ID " + id));
> {code}
> Also, I think the separate check for container existence is unnecessary, SCM 
> can handle attempts to close non-existent containers.  With the current code 
> SCM needs to be contacted for both requests.
> The goals of this task:
> # provide more meaningful message in the {{ContainerNotFoundException}}, e.g. 
> {{"Container " + id + " not found"}}
> # remove the {{checkContainerExists}} method and its only usage in 
> {{CloseSubcommand}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to