errose28 commented on a change in pull request #3051:
URL: https://github.com/apache/ozone/pull/3051#discussion_r820007893



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -3087,37 +3121,48 @@ public S3VolumeContext getS3VolumeContext() throws 
IOException {
     String userPrincipal = Server.getRemoteUser().getShortUserName();
 
     if (s3Auth != null) {
-      String accessID = s3Auth.getAccessId();
-      // TODO HDDS-6063: Volume lock is needed here along with the other
-      //  multi-tenant read requests.
+      String accessId = s3Auth.getAccessId();
       Optional<String> optionalTenantId =
-          multiTenantManager.getTenantForAccessID(accessID);
+          multiTenantManager.getTenantForAccessID(accessId);
 
       if (optionalTenantId.isPresent()) {
-        String tenantId = optionalTenantId.get();
+        final String tenantId = optionalTenantId.get();
+
         OmDBTenantInfo tenantInfo =
             metadataManager.getTenantStateTable().get(tenantId);
         if (tenantInfo != null) {
           s3Volume = metadataManager.getTenantStateTable().get(tenantId)
               .getBucketNamespaceName();
         } else {
           String message = "Expected to find a tenant for access ID " +
-              accessID +
+              accessId +
               " but no tenant was found. Possibly inconsistent OM DB!";
           LOG.error(message);
           throw new OMException(message, ResultCodes.TENANT_NOT_FOUND);

Review comment:
       The tenant may have been removed since we are not holding a lock. We can 
lighten up the message and log it as a warning instead of an error. We should 
keep the exception though.

##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -3087,37 +3121,48 @@ public S3VolumeContext getS3VolumeContext() throws 
IOException {
     String userPrincipal = Server.getRemoteUser().getShortUserName();
 
     if (s3Auth != null) {
-      String accessID = s3Auth.getAccessId();
-      // TODO HDDS-6063: Volume lock is needed here along with the other
-      //  multi-tenant read requests.
+      String accessId = s3Auth.getAccessId();
       Optional<String> optionalTenantId =
-          multiTenantManager.getTenantForAccessID(accessID);
+          multiTenantManager.getTenantForAccessID(accessId);
 
       if (optionalTenantId.isPresent()) {
-        String tenantId = optionalTenantId.get();
+        final String tenantId = optionalTenantId.get();
+
         OmDBTenantInfo tenantInfo =
             metadataManager.getTenantStateTable().get(tenantId);
         if (tenantInfo != null) {
           s3Volume = metadataManager.getTenantStateTable().get(tenantId)
               .getBucketNamespaceName();

Review comment:
       This was a mistake in the original implementation. It should be  
`s3Volume = tenantInfo.getBucketNamespaceName();`

##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -3087,37 +3121,48 @@ public S3VolumeContext getS3VolumeContext() throws 
IOException {
     String userPrincipal = Server.getRemoteUser().getShortUserName();
 
     if (s3Auth != null) {
-      String accessID = s3Auth.getAccessId();
-      // TODO HDDS-6063: Volume lock is needed here along with the other
-      //  multi-tenant read requests.
+      String accessId = s3Auth.getAccessId();
       Optional<String> optionalTenantId =
-          multiTenantManager.getTenantForAccessID(accessID);
+          multiTenantManager.getTenantForAccessID(accessId);
 
       if (optionalTenantId.isPresent()) {
-        String tenantId = optionalTenantId.get();
+        final String tenantId = optionalTenantId.get();
+
         OmDBTenantInfo tenantInfo =
             metadataManager.getTenantStateTable().get(tenantId);
         if (tenantInfo != null) {
           s3Volume = metadataManager.getTenantStateTable().get(tenantId)
               .getBucketNamespaceName();
         } else {
           String message = "Expected to find a tenant for access ID " +
-              accessID +
+              accessId +
               " but no tenant was found. Possibly inconsistent OM DB!";
           LOG.error(message);
           throw new OMException(message, ResultCodes.TENANT_NOT_FOUND);
         }
         if (LOG.isDebugEnabled()) {
           LOG.debug("Get S3 volume request for access ID {} belonging to " +
-                  "tenant {} is directed to the volume {}.", accessID, 
tenantId,
+                  "tenant {} is directed to the volume {}.", accessId, 
tenantId,
               s3Volume);
         }
 
-        // Inject user name to the response to be used for KMS on the client
-        userPrincipal = OzoneAclUtils.accessIdToUserPrincipal(accessID);
+        boolean acquiredVolumeLock =
+            getMetadataManager().getLock().acquireWriteLock(

Review comment:
       We should only need a read lock here right?




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