jerqi commented on code in PR #9507:
URL: https://github.com/apache/gravitino/pull/9507#discussion_r2638898368


##########
clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/DefaultGravitinoFileSystemCredentialsProvider.java:
##########
@@ -51,10 +56,31 @@ public Credential[] getCredentials() {
     // The format of name identifier is `metalake.catalog.schema.fileset`
     String nameIdentifier = configuration.get(GVFS_NAME_IDENTIFIER);
     String[] idents = nameIdentifier.split("\\.");
+
     try (GravitinoClient client = 
GravitinoVirtualFileSystemUtils.createClient(configuration)) {
       FilesetCatalog filesetCatalog = 
client.loadCatalog(idents[1]).asFilesetCatalog();
       Fileset fileset = 
filesetCatalog.loadFileset(NameIdentifier.of(idents[2], idents[3]));
+
+      String targetLocationName = getTargetLocation(fileset);
+      
GravitinoVirtualFileSystemUtils.setCallerContextForGetCredentials(targetLocationName);
+
       return fileset.supportsCredentials().getCredentials();
+    } finally {
+      CallerContext.CallerContextHolder.remove();
     }
   }
+
+  private String getTargetLocation(Fileset fileset) {
+    String currentLocationEnvVar =
+        configuration.get(
+            
GravitinoVirtualFileSystemConfiguration.FS_GRAVITINO_CURRENT_LOCATION_NAME_ENV_VAR,
+            GravitinoVirtualFileSystemConfiguration
+                .FS_GRAVITINO_CURRENT_LOCATION_NAME_ENV_VAR_DEFAULT);
+    String locationName =
+        
Optional.ofNullable(configuration.get(FS_GRAVITINO_CURRENT_LOCATION_NAME))
+            .orElse(System.getenv(currentLocationEnvVar));
+    return locationName == null
+        ? fileset.properties().get(PROPERTY_DEFAULT_LOCATION_NAME)
+        : locationName;
+  }

Review Comment:
   Actually, the test cases didn't take effect before. I fix the tests to cover 
fileset with multiple locations credential vending issues.



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

Reply via email to