You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Attila Doroszlai (Jira)" <ji...@apache.org> on 2023/12/04 14:05:00 UTC

[jira] [Created] (HDDS-9827) Cryptic response when trying to close non-existent container from CLI

Attila Doroszlai created HDDS-9827:
--------------------------------------

             Summary: 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: Bug
          Components: Ozone CLI
            Reporter: Attila Doroszlai


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}

I think the additional 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.



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

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