You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "swamirishi (via GitHub)" <gi...@apache.org> on 2024/07/10 17:41:40 UTC

[PR] HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail [ozone]

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

   
   ## What changes were proposed in this pull request?
   With the introduction of a new client version in https://issues.apache.org/jira/browse/HDDS-10983, the latest version is 4.
   The OLDER_CLIENT_REQUEST validation checked against the latest versions for access to newer non-legacy buckets but since the addition of a newer version all client versions prior to 4 becomes an older client. This blocks access to OBS/FSO buckets and EC key lookups for older clients version 2 & 3.
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-11132
   
   ## How was this patch tested?
   Unit tests need to be added.


-- 
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-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail [ozone]

Posted by "errose28 (via GitHub)" <gi...@apache.org>.
errose28 commented on PR #6922:
URL: https://github.com/apache/ozone/pull/6922#issuecomment-2225830900

   @swamirishi should we close this in favor of #6932 to avoid confusion?


-- 
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-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #6922:
URL: https://github.com/apache/ozone/pull/6922#discussion_r1676161266


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -287,13 +288,17 @@ private boolean bucketContainsSnapshotInCache(
   )
   public static OMRequest blockBucketDeleteWithBucketLayoutFromOldClient(
       OMRequest req, ValidationContext ctx) throws IOException {
-    DeleteBucketRequest request = req.getDeleteBucketRequest();
-
-    if (request.hasBucketName() && request.hasVolumeName()) {
-      BucketLayout bucketLayout = ctx.getBucketLayout(
-          request.getVolumeName(), request.getBucketName());
-      bucketLayout.validateSupportedOperation();
+    if (ClientVersion.fromProtoValue(req.getVersion())
+        .compareTo(ClientVersion.BUCKET_LAYOUT_SUPPORT) < 0) {
+      DeleteBucketRequest request = req.getDeleteBucketRequest();
+
+      if (request.hasBucketName() && request.hasVolumeName()) {
+        BucketLayout bucketLayout = ctx.getBucketLayout(
+            request.getVolumeName(), request.getBucketName());
+        bucketLayout.validateSupportedOperation();
+      }
     }
     return req;

Review Comment:
   I'd suggest:
   
   ```java
   ClientVersion.BUCKET_LAYOUT_SUPPORT.isSupportedByClient(req.getVersion())
   ```
   
   (which also highlights why "SUPPORT" shouldn't be part of the enum constant name...)



-- 
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-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #6922:
URL: https://github.com/apache/ozone/pull/6922#discussion_r1672737993


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -287,13 +288,17 @@ private boolean bucketContainsSnapshotInCache(
   )
   public static OMRequest blockBucketDeleteWithBucketLayoutFromOldClient(
       OMRequest req, ValidationContext ctx) throws IOException {
-    DeleteBucketRequest request = req.getDeleteBucketRequest();
-
-    if (request.hasBucketName() && request.hasVolumeName()) {
-      BucketLayout bucketLayout = ctx.getBucketLayout(
-          request.getVolumeName(), request.getBucketName());
-      bucketLayout.validateSupportedOperation();
+    if (ClientVersion.fromProtoValue(req.getVersion())
+        .compareTo(ClientVersion.BUCKET_LAYOUT_SUPPORT) < 0) {
+      DeleteBucketRequest request = req.getDeleteBucketRequest();
+
+      if (request.hasBucketName() && request.hasVolumeName()) {
+        BucketLayout bucketLayout = ctx.getBucketLayout(
+            request.getVolumeName(), request.getBucketName());
+        bucketLayout.validateSupportedOperation();
+      }
     }
     return req;

Review Comment:
   The same "return early if client is new enough" check can be added in all methods (changing only the enum value being compared to, and the return type (request/response)):
   
   ```java
       ClientVersion clientVersion = ClientVersion.fromProtoValue(req.getVersion());
       if (ClientVersion.BUCKET_LAYOUT_SUPPORT.compareTo(clientVersion) <= 0) {
         return req;
       }
   ```
   
   That would:
   - simplify this change,
   - help avoid checkstyle problems,
   - make the logic easier to understand for future readers of the code,
   - prepare for the future refactoring discussed in #6919.
   
   ```suggestion
       ClientVersion clientVersion = ClientVersion.fromProtoValue(req.getVersion());
       if (ClientVersion.BUCKET_LAYOUT_SUPPORT.compareTo(clientVersion) <= 0) {
         return req;
       }
   
       DeleteBucketRequest request = req.getDeleteBucketRequest();
   
       if (request.hasBucketName() && request.hasVolumeName()) {
         BucketLayout bucketLayout = ctx.getBucketLayout(
             request.getVolumeName(), request.getBucketName());
         bucketLayout.validateSupportedOperation();
       }
       return req;
   ```



-- 
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-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail [ozone]

Posted by "fapifta (via GitHub)" <gi...@apache.org>.
fapifta commented on code in PR #6922:
URL: https://github.com/apache/ozone/pull/6922#discussion_r1676090446


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -287,13 +288,17 @@ private boolean bucketContainsSnapshotInCache(
   )
   public static OMRequest blockBucketDeleteWithBucketLayoutFromOldClient(
       OMRequest req, ValidationContext ctx) throws IOException {
-    DeleteBucketRequest request = req.getDeleteBucketRequest();
-
-    if (request.hasBucketName() && request.hasVolumeName()) {
-      BucketLayout bucketLayout = ctx.getBucketLayout(
-          request.getVolumeName(), request.getBucketName());
-      bucketLayout.validateSupportedOperation();
+    if (ClientVersion.fromProtoValue(req.getVersion())
+        .compareTo(ClientVersion.BUCKET_LAYOUT_SUPPORT) < 0) {
+      DeleteBucketRequest request = req.getDeleteBucketRequest();
+
+      if (request.hasBucketName() && request.hasVolumeName()) {
+        BucketLayout bucketLayout = ctx.getBucketLayout(
+            request.getVolumeName(), request.getBucketName());
+        bucketLayout.validateSupportedOperation();
+      }
     }
     return req;

Review Comment:
   I would even go further a bit...
   What if we define a method in the ClientVersion enum, call it let's say isNewerThan(ClientVersion), and use that instead of the compareTo?
   With that this block can be reduced to an if (ClientVersion.fromProtoValue(req.getVersion()).isNewerThan(ClientVersion.BUCKET_LAYOUT_SUPPORT))
   
   An other option may be (though it means introducing a new method for every version) to add a static method named like isNewerThanBucketLayout(int version), do the proto to enum conversion in the method than the compareTo, and return a boolen, so that the usage would look like:
   if (ClientVersion.isNewerThanBucketLayout(req.getVersion()))



-- 
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-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail [ozone]

Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi closed pull request #6922: HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail
URL: https://github.com/apache/ozone/pull/6922


-- 
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-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #6922:
URL: https://github.com/apache/ozone/pull/6922#discussion_r1672737993


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -287,13 +288,17 @@ private boolean bucketContainsSnapshotInCache(
   )
   public static OMRequest blockBucketDeleteWithBucketLayoutFromOldClient(
       OMRequest req, ValidationContext ctx) throws IOException {
-    DeleteBucketRequest request = req.getDeleteBucketRequest();
-
-    if (request.hasBucketName() && request.hasVolumeName()) {
-      BucketLayout bucketLayout = ctx.getBucketLayout(
-          request.getVolumeName(), request.getBucketName());
-      bucketLayout.validateSupportedOperation();
+    if (ClientVersion.fromProtoValue(req.getVersion())
+        .compareTo(ClientVersion.BUCKET_LAYOUT_SUPPORT) < 0) {
+      DeleteBucketRequest request = req.getDeleteBucketRequest();
+
+      if (request.hasBucketName() && request.hasVolumeName()) {
+        BucketLayout bucketLayout = ctx.getBucketLayout(
+            request.getVolumeName(), request.getBucketName());
+        bucketLayout.validateSupportedOperation();
+      }
     }
     return req;

Review Comment:
   The same "return early if client is new enough" check can be added in all methods (changing only the enum value being compared to, and the return type (request/response)):
   
   ```java
       ClientVersion clientVersion = ClientVersion.fromProtoValue(req.getVersion());
       if (ClientVersion.BUCKET_LAYOUT_SUPPORT.compareTo(clientVersion) <= 0) {
         return req;
       }
   ```
   
   That would:
   - simplify this change,
   - make the logic easier to understand for future readers of the code,
   - prepare for the future refactoring discussed in #6919.
   
   ```suggestion
       ClientVersion clientVersion = ClientVersion.fromProtoValue(req.getVersion());
       if (ClientVersion.BUCKET_LAYOUT_SUPPORT.compareTo(clientVersion) <= 0) {
         return req;
       }
   
       DeleteBucketRequest request = req.getDeleteBucketRequest();
   
       if (request.hasBucketName() && request.hasVolumeName()) {
         BucketLayout bucketLayout = ctx.getBucketLayout(
             request.getVolumeName(), request.getBucketName());
         bucketLayout.validateSupportedOperation();
       }
       return req;
   ```



-- 
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-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail [ozone]

Posted by "swamirishi (via GitHub)" <gi...@apache.org>.
swamirishi commented on code in PR #6922:
URL: https://github.com/apache/ozone/pull/6922#discussion_r1672746288


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -287,13 +288,17 @@ private boolean bucketContainsSnapshotInCache(
   )
   public static OMRequest blockBucketDeleteWithBucketLayoutFromOldClient(
       OMRequest req, ValidationContext ctx) throws IOException {
-    DeleteBucketRequest request = req.getDeleteBucketRequest();
-
-    if (request.hasBucketName() && request.hasVolumeName()) {
-      BucketLayout bucketLayout = ctx.getBucketLayout(
-          request.getVolumeName(), request.getBucketName());
-      bucketLayout.validateSupportedOperation();
+    if (ClientVersion.fromProtoValue(req.getVersion())
+        .compareTo(ClientVersion.BUCKET_LAYOUT_SUPPORT) < 0) {
+      DeleteBucketRequest request = req.getDeleteBucketRequest();
+
+      if (request.hasBucketName() && request.hasVolumeName()) {
+        BucketLayout bucketLayout = ctx.getBucketLayout(
+            request.getVolumeName(), request.getBucketName());
+        bucketLayout.validateSupportedOperation();
+      }
     }
     return req;

Review Comment:
   yeah sure will make this change add it in a separate if block



-- 
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-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org