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


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java:
##########
@@ -135,6 +135,9 @@ public OMRequest preExecute(OzoneManager ozoneManager) 
throws IOException {
     newBucketInfo.setCreationTime(initialTime)
         .setModificationTime(initialTime);
 
+    // reset usage counters to 0 to prevent arbitrary values set in the 
request by any other client
+    
newBucketInfo.clearUsedBytes().clearUsedNamespace().clearSnapshotUsedBytes().clearSnapshotUsedNamespace();

Review Comment:
   nit: the previous commit better fit existing style
   
   
https://github.com/apache/ozone/blob/bedd5f838278a9a6c5f0ef98eb1dbf86a9e9fd5c/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java#L139-L142
   
   (One call per line is easier to read and better for future changes.)



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/bucket/TestOMBucketCreateRequest.java:
##########
@@ -126,6 +126,23 @@ public void testValidateAndUpdateCache() throws Exception {
 
   }
 
+  @Test
+  public void testNewBucketIgnoresUsageCountersFromRequest() throws Exception {
+    String volumeName = UUID.randomUUID().toString();
+    String bucketName = UUID.randomUUID().toString();
+
+    OMBucketCreateRequest omBucketCreateRequest = 
doPreExecute(newBucketInfoBuilder(bucketName, volumeName)
+        
.setUsedBytes(1000L).setUsedNamespace(10L).setSnapshotUsedBytes(100L).setSnapshotUsedNamespace(1L));

Review Comment:
   Same nit here:
   
   
https://github.com/apache/ozone/blob/bedd5f838278a9a6c5f0ef98eb1dbf86a9e9fd5c/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/bucket/TestOMBucketCreateRequest.java#L134-L138



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