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

   ## What changes were proposed in this pull request?
   
   This error was coming from `OzoneAddress.ensureBucketAddress()` but if we 
were to modify that method to accept the snapshot name as part of the keyName 
while checking a bucket path, then every bucket command would accept a snapshot 
path appended to it. Therefore, `ozone sh key list` couldn't work with a 
snapshot without having other unwanted commands doing it as well.
   
   In order to fix this, a new command was added, `ozone sh snapshot key-list` 
which extends a new class `SnapshotHandler` that calls `SnapshotUri.convert()` 
and from `OzoneAddress.ensureSnapshotAddress()` checks for a snapshot prefix 
and name. This method could be modified and extended in the future to accept 
keys under the snapshot address.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-7277
   
   ## How was this patch tested?
   
   A new unit test was added for checking the snapshot address. Also, this 
patch was tested manually in a docker cluster like so
   
   in `/hadoop-ozone/dist/target/ozone-1.3.0-SNAPSHOT/compose/ozone`
   ```
   ❯ docker-compose up --scale datanode=3 -d
   
   ❯ docker exec -it ozone_om_1 bash
   bash-4.2$ ozone sh volume create /vol1
   bash-4.2$ ozone sh bucket create /vol1/bucket1
   bash-4.2$ ozone sh key put /vol1/bucket1/key1 /etc/hosts
   bash-4.2$ ozone sh key put /vol1/bucket1/dir1/key2 /etc/os-release
   bash-4.2$ ozone sh snapshot create /vol1/bucket1 snap1
   bash-4.2$ ozone sh snapshot key-list /vol1/bucket1/.snapshot/snap1
   [ {
     "volumeName" : "vol1",
     "bucketName" : "bucket1",
     "name" : ".snapshot/snap1/dir1/key2",
     "dataSize" : 393,
     "creationTime" : "2022-12-23T18:23:36.063Z",
     "modificationTime" : "2022-12-23T18:23:36.827Z",
     "replicationConfig" : {
       "replicationFactor" : "THREE",
       "requiredNodes" : 3,
       "replicationType" : "RATIS"
     }
   }, {
     "volumeName" : "vol1",
     "bucketName" : "bucket1",
     "name" : ".snapshot/snap1/key1",
     "dataSize" : 174,
     "creationTime" : "2022-12-23T18:23:22.899Z",
     "modificationTime" : "2022-12-23T18:23:23.920Z",
     "replicationConfig" : {
       "replicationFactor" : "THREE",
       "requiredNodes" : 3,
       "replicationType" : "RATIS"
     }
   } ]
   bash-4.2$ ozone sh snapshot key-list --prefix=dir1 
/vol1/bucket1/.snapshot/snap1
   [ {
     "volumeName" : "vol1",
     "bucketName" : "bucket1",
     "name" : ".snapshot/snap1/dir1/key2",
     "dataSize" : 393,
     "creationTime" : "2022-12-23T18:23:36.063Z",
     "modificationTime" : "2022-12-23T18:23:36.827Z",
     "replicationConfig" : {
       "replicationFactor" : "THREE",
       "requiredNodes" : 3,
       "replicationType" : "RATIS"
     }
   } ]
   bash-4.2$ ozone sh snapshot key-list --prefix=.snapshot/snap1/dir1 
/vol1/bucket1                
   Invalid value for positional parameter at index 0 (<value>): cannot convert 
'/vol1/bucket1' to OzoneAddress 
(org.apache.hadoop.ozone.client.OzoneClientException: Snapshot name is missing.)
   ```
   


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