FANNG1 commented on code in PR #5974:
URL: https://github.com/apache/gravitino/pull/5974#discussion_r1904991200


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/fs/GCSFileSystemProvider.java:
##########
@@ -43,6 +46,18 @@ public FileSystem getFileSystem(Path path, Map<String, 
String> config) throws IO
     Configuration configuration = new Configuration();
     FileSystemUtils.toHadoopConfigMap(config, GRAVITINO_KEY_TO_GCS_HADOOP_KEY)
         .forEach(configuration::set);
+
+    // This is a workaround to judge whether it's from a Gravitino GVFS client.
+    if 
(config.containsKey(GravitinoVirtualFileSystemConfiguration.FS_GRAVITINO_SERVER_URI_KEY))
 {
+      AccessTokenProvider accessTokenProvider = new GCSCredentialsProvider();
+      accessTokenProvider.setConf(configuration);
+      // Why is this check necessary?if Gravitino fails to get any 
credentials, we fall back to
+      // the default behavior of the GoogleHadoopFileSystem to use service 
account credentials.
+      if (accessTokenProvider.getAccessToken() != null) {
+        configuration.set(GCS_TOKEN_PROVIDER_IMPL, 
GCSCredentialsProvider.class.getName());
+      }
+    }

Review Comment:
   +1, this is more clear, if credential vending is enabled in the server side, 
use server credentials; if not,  use credentials in client side.



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