Skip to content

Conversation

@will-sh
Copy link
Contributor

@will-sh will-sh commented Jul 16, 2024

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

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

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

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

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

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

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

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

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

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

…ient/HddsClientUtils.java

Co-authored-by: Sadanand Shenoy <sadanand.shenoy4898@gmail.com>
@sadanand48
Copy link
Contributor

Thanks @will-sh for the patch, LGTM.

@sadanand48 sadanand48 merged commit abf3a0a into apache:master Jul 17, 2024
@will-sh
Copy link
Contributor Author

will-sh commented Jul 17, 2024

Thanks for the review. @sadanand48

errose28 added a commit to errose28/ozone that referenced this pull request Jul 30, 2024
…-delete

* HDDS-10239-container-reconciliation: (184 commits)
  HDDS-10373. Implement framework for capturing Merkle Tree Metrics. (apache#6864)
  HDDS-11188. Initial setup for new UI layout and enable users to switch to new UI (apache#6953)
  HDDS-11120. Rich rebalancing status info (apache#6911)
  HDDS-11187. Fix Event Handling in Recon OMDBUpdatesHandler to Prevent ClassCastException. (apache#6950)
  HDDS-11213. Bump commons-daemon to 1.4.0 (apache#6971)
  HDDS-11212. Bump commons-net to 3.11.1 (apache#6973)
  HDDS-11211. Bump assertj-core to 3.26.3 (apache#6972)
  HDDS-11210. Bump log4j2 to 2.23.1 (apache#6970)
  HDDS-11150. Recon Overview page crashes due to failed API Calls (apache#6944)
  HDDS-11183. Keys from DeletedTable and DeletedDirTable of AOS should be deleted on batch operation while creating a snapshot (apache#6946)
  HDDS-11198. Fix Typescript configs for Recon (apache#6961)
  HDDS-11180. Simplify HttpServer2#inferMimeType return statement (apache#6963)
  HDDS-11194. OM missing audit log for upgrade (apache#6958)
  HDDS-10389. Implement a search feature for users to locate open keys within the Open Keys Insights section. (apache#6231)
  HDDS-10561. Dashboard for delete key metrics (apache#6948)
  HDDS-11192. Increase SPNEGO URL test coverage (apache#6956)
  HDDS-11179. DBConfigFromFile#readFromFile result of toIOException not thrown (apache#6957)
  HDDS-11186. First container log missing from bundle (apache#6952)
  HDDS-10844. Clarify snapshot create error message. (apache#6955)
  HDDS-11166. Switch to Rocky Linux-based ozone-runner (apache#6942)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants