will-sh opened a new pull request, #6955: URL: https://github.com/apache/ozone/pull/6955
## What changes were proposed in this pull request? HDDS-10844. Clarify snapshot create error message Please describe your PR in detail: * Show the specific reason why the snapshot name is invalid by throwing the specific IllegalArgumentException using `e.getMessage()` * Enhance HddsClientUtils.verifyResourceName to support validation for volumes, buckets, and snapshots by introducing a resType parameter. This modification allows specifying the resource type in error messages, making them more context-specific. Usage examples: HddsClientUtils.verifyResourceName(snapshotName, "snapshot"); HddsClientUtils.verifyResourceName(volumeName, "volume", isStrictS3); HddsClientUtils.verifyResourceName(bucketName, "bucket", isStrictS3); Example output: docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 s1" INVALID_SNAPSHOT_ERROR snapshot length is illegal, valid length is 3-63 characters If don't pass resType into verifyResourceName, it will show default resType as string "resource" Previously, the method generated fixed error messages such as "Bucket or Volume name has an unsupported character". This update ensures the error messages are relevant to the type of resource being validated, addressing inaccuracies when used with volumes, buckets, and snapshots. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-10844 ## How was this patch tested? Tested below scenarios in local docker according to hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java 1. docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket s1" INVALID_SNAPSHOT_ERROR Invalid snapshot name: s1 snapshot length is illegal, valid length is 3-63 characters 2. docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 .s1" INVALID_SNAPSHOT_ERROR Invalid snapshot name: .s1 snapshot name cannot start with a period or dash 3. docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 s1." INVALID_SNAPSHOT_ERROR Invalid snapshot name: s1. snapshot name cannot end with a period or dash docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 s1-" INVALID_SNAPSHOT_ERROR Invalid snapshot name: s1- snapshot name cannot end with a period or dash 4. docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 ssA" INVALID_SNAPSHOT_ERROR Invalid snapshot name: ssA snapshot name does not support uppercase characters 5. docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 s%s" INVALID_SNAPSHOT_ERROR Invalid snapshot name: s%s snapshot name has an unsupported character : % 6. docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 s..s" INVALID_SNAPSHOT_ERROR Invalid snapshot name: s..s snapshot name should not have two contiguous periods 7. docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 s-.s" INVALID_SNAPSHOT_ERROR Invalid snapshot name: s-.s snapshot name should not have period after dash 8. docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 s.-s" INVALID_SNAPSHOT_ERROR Invalid snapshot name: s.-s snapshot name should not have dash after period 9. docker exec -it ozone-om-1 sh -c "ozone sh snapshot create /s3v/bucket1 192.168.1.1" INVALID_SNAPSHOT_ERROR Invalid snapshot name: 192.168.1.1 snapshotBucket or Volume name cannot be an IPv4 address or all numeric -- 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: issues-unsubscr...@ozone.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org