rakeshadr commented on code in PR #3411:
URL: https://github.com/apache/ozone/pull/3411#discussion_r876705930


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -192,4 +198,38 @@ public OMClientResponse 
validateAndUpdateCache(OzoneManager ozoneManager,
     }
   }
 
+  /**
+   * Validates bucket delete requests.
+   * Handles the cases where an older client attempts to delete a bucket
+   * a new bucket layout.
+   * We do not want to allow this to happen, since this would cause the client
+   * to be able to delete buckets it cannot understand.
+   *
+   * @param req - the request to validate
+   * @param ctx - the validation context
+   * @return the validated request
+   * @throws OMException if the request is invalid
+   */
+  @RequestFeatureValidator(
+      conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
+      processingPhase = RequestProcessingPhase.PRE_PROCESS,
+      requestType = Type.DeleteBucket
+  )
+  public static OMRequest blockBucketDeleteWithBucketLayoutFromOldClient(
+      OMRequest req, ValidationContext ctx) throws IOException {
+    DeleteBucketRequest request = req.getDeleteBucketRequest();
+
+    if (request.hasBucketName() && request.hasVolumeName() &&
+        !ctx.getBucketLayout(

Review Comment:
   @JyotinderSingh Its duplicated everywhere. Please move this to BucketLayout 
and do something like below:
   
   ```
   BucketLayout.java
   
     /**
      * Add javadoc....
      *
      * @throws OMException
      */
     void validateSupportedOperation() throws OMException {
       if (!isLegacy()) {
   
         throw new OMException("Client is attempting to delete a bucket which" +
             " uses non-LEGACY bucket layout features. Please upgrade the" +
             " client to a compatible version before trying to delete" +
             " the bucket.",
             OMException.ResultCodes.NOT_SUPPORTED_OPERATION);
       }
     }
   ```
   
   ```
   BucketLayout buckLayout = ctx.getBucketLayout(
                 keyArgs.getVolumeName(), keyArgs.getBucketName());
   buckLayout.validateSupportedOperation();
   ```



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