adoroszlai commented on code in PR #9462:
URL: https://github.com/apache/ozone/pull/9462#discussion_r2616794403


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java:
##########
@@ -93,9 +94,41 @@ public OMRequest preExecute(OzoneManager ozoneManager) 
throws IOException {
     CreateBucketRequest createBucketRequest =
         getOmRequest().getCreateBucketRequest();
     BucketInfo bucketInfo = createBucketRequest.getBucketInfo();
+
+    // Convert BucketLayoutProto -> BucketLayout enum.
+    BucketLayout bucketLayout =
+        BucketLayout.valueOf(bucketInfo.getBucketLayout().name());
+
+    // Determine if this bucket belongs to the S3 namespace.
+    String s3VolumeName = ozoneManager.getConfiguration().get(
+        OzoneConfigKeys.OZONE_S3_VOLUME_NAME,
+        OzoneConfigKeys.OZONE_S3_VOLUME_NAME_DEFAULT);
+    boolean isS3Bucket =
+        s3VolumeName != null && 
s3VolumeName.equals(bucketInfo.getVolumeName());
+
+    // Compute effectiveStrict based on global strict flag, S3 namespace,
+    // and bucket layout.
+    boolean globalStrict = ozoneManager.isStrictS3();
+    boolean effectiveStrict = globalStrict;
+
+
+    // When strict=false, only S3 buckets with FSO layout should allow
+    // non-S3-compliant characters (e.g. underscore).
+    // All other S3 bucket layouts must still enforce strict naming rules.
+    if (!globalStrict && isS3Bucket) {
+      if (bucketLayout == BucketLayout.FILE_SYSTEM_OPTIMIZED) {
+        // S3 + FSO + strict=false → bypass strict S3 validation (allow '_' 
and other non-S3 characters)
+        effectiveStrict = false;
+      } else {
+        // S3 + non-FSO + strict=false → strict S3 validation still applies
+        // '_' and other non-S3 characters are not permitted
+        effectiveStrict = true;
+      }
+    }
+
     // Verify resource name
     OmUtils.validateBucketName(bucketInfo.getBucketName(),
-        ozoneManager.isStrictS3());
+        effectiveStrict);

Review Comment:
   1. Considering bucket links, multitenancy, and that S3 volume name can be 
updated in the config, I don't think this should be restricted to buckets in 
the S3 volume.
   2. Check eligibility using `bucketLayout#isObjectStore` to handle `LEGACY`, 
too.
   3. Use existing conversion logic `BucketLayout#fromProto`.
   
   ```suggestion
       BucketLayout bucketLayout = 
BucketLayout.fromProto(bucketInfo.getBucketLayout());
       boolean strict = ozoneManager.isStrictS3()
           || 
bucketLayout.isObjectStore(ozoneManager.getConfig().isFileSystemPathEnabled());
       OmUtils.validateBucketName(bucketInfo.getBucketName(), strict);
   ```



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