duongnguyen0 opened a new pull request, #3517:
URL: https://github.com/apache/ozone/pull/3517

   
   ## What changes were proposed in this pull request?
   Command-line tools don't take exit-code from `picocli` and set the exit-code 
accordingly. That makes exit-codes for cases like invalid argument be always 0.
   
   This change fix that by replacing the use of the deprecated 
`parseWithHandler` method with the `execute` method that returns correct 
exit-code for parsing/invalid input cases. 
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-6882
   
   ## How was this patch tested?
   Regression is checked by unit test.
   
   Manually tests to verify the expected status code for error-cases.
   
   ```
   ozone sh bucket create /vol1/bucket1 -l 123
   Invalid value for option '--layout': expected one of [FILE_SYSTEM_OPTIMIZED, 
OBJECT_STORE, LEGACY] (case-sensitive) but was '123'
   Usage: ozone sh bucket create [-ghV] [-k=<bekName>] 
[-l=<allowedBucketLayout>]
                                 [--namespace-quota=<quotaInNamespace>]
                                 [--quota=<quotaInBytes>] [-r=<replication>]
                                 [-t=<type>] [-u=<ownerName>] <value>
   creates a bucket in a given volume
         <value>              URI of the volume/bucket.
                              Ozone URI could start with o3:// or without 
prefix.
                                URI may contain the host/serviceId and port of 
the
                                OM server. Both are optional. If they are not
                                specified it will be identified from the config
                                files.
     -g, --enforcegdpr        if true, indicates GDPR enforced bucket,
                                false/unspecified indicates otherwise
     -h, --help               Show this help message and exit.
     -k, --bucketkey=<bekName>
                              bucket encryption key name
     -l, --layout=<allowedBucketLayout>
                              Allowed Bucket Layouts: FILE_SYSTEM_OPTIMIZED,
                                OBJECT_STORE, LEGACY
         --namespace-quota=<quotaInNamespace>
                              For volume this parameter represents the number of
                                buckets, and for buckets represents the number 
of
                                keys (eg. 5)
         --quota, --space-quota=<quotaInBytes>
                              The maximum space quota can be used (eg. 1GB)
     -r, --replication=<replication>
                              Replication definition. Valid values are 
replication
                                type-specific.  For RATIS: ONE or THREE. In case
                                of EC, pass CODEC-DATA-PARITY-CHUNKSIZE,  e.g.
                                rs-3-2-1024k, rs-6-3-1024k, rs-10-4-1024k
     -t, --type, --replication-type=<type>
                              Replication type. Supported types are: RATIS, EC
     -u, --user=<ownerName>   Owner of the bucket. Defaults to current user if 
not
                                specified
     -V, --version            Print version information and exit.
   sh-4.2$ echo $?
   2
   
   sh-4.2$ ozone sh bucket create /vol1/bucket_1
   INVALID_BUCKET_NAME Bucket or Volume name has an unsupported character : _
   sh-4.2$ echo $?
   255
   
   sh-4.2$ ozone sh bucket create /vol1/bucket1
   2022-06-14 23:06:01,060 INFO  rpc.RpcClient 
(RpcClient.java:createVolume(466)) - Creating Volume: vol1, with duong as owner 
and space quota set to -1 bytes, counts quota set to -1
   sh-4.2$ echo $?
   0
   
   ```
   


-- 
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