You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "FANNG1 (via GitHub)" <gi...@apache.org> on 2025/01/08 01:28:13 UTC

[PR] [SIP] fix gcs error [gravitino]

FANNG1 opened a new pull request, #6141:
URL: https://github.com/apache/gravitino/pull/6141

   <!--
   1. Title: [#<issue>] <type>(<scope>): <subject>
      Examples:
        - "[#123] feat(operator): support xxx"
        - "[#233] fix: check null before access result in xxx"
        - "[MINOR] refactor: fix typo in variable name"
        - "[MINOR] docs: fix typo in README"
        - "[#255] test: fix flaky test NameOfTheTest"
      Reference: https://www.conventionalcommits.org/en/v1.0.0/
   2. If the PR is unfinished, please mark this PR as draft.
   -->
   
   ### What changes were proposed in this pull request?
   
   (Please outline the changes and how this PR fixes the issue.)
   
   ### Why are the changes needed?
   
   (Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, describe the bug.)
   
   Fix: # (issue)
   
   ### Does this PR introduce _any_ user-facing change?
   
   (Please list the user-facing changes introduced by your change, including
     1. Change in user-facing APIs.
     2. Addition or removal of property keys.)
   
   ### How was this patch tested?
   
   (Please test your changes, and provide instructions on how to test it:
     1. If you add a feature or fix a bug, add a test to cover your changes.
     2. If you fix a flaky test, repeat it for many times to prove it works.)
   


-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more permission to support fileset operations [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1906847033


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)

Review Comment:
   It's the behaviour of Hadoop GCS connector to check subpath info to check path exists. so no need to add write permission.



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more GCS permission to support fileset operations [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1908056016


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   What I 'm trying to say: Is this a proper way to solve this problem?  If the path is very long, say have the item may be very large. 
   
   In the example above, I can use the prefix condition of the path to control the permission in IAM, so I wonder If we can do similar operation in for credentails.



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more GCS permission to support fileset operations [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1908236999


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   Role only_list_object_in_bucket
   ![image](https://github.com/user-attachments/assets/762ad4c5-3887-4a5d-8233-fa4ae59d221b)
   
   Role: iam_role1
   <img width="869" alt="image" src="https://github.com/user-attachments/assets/11ba1b0d-ba67-446e-9628-1bfae334021e" />
   



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more GCS permission to support fileset operations [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1908099359


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   Could you pass fileset IT with these roles?



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more GCS permission to support fileset operations [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 merged PR #6141:
URL: https://github.com/apache/gravitino/pull/6141


-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more permission to support fileset operations [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1906850133


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   Take `a/b/c` for example,  without this,  only grant the permission for  the path start with `a/b/c`, but HADOOP GCS connector need the storage read perssion for `a/` `a/b/`  too. 



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more permission to support fileset operations [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1908011599


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   sorry, I couldn't get your point, what's the problem here?



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more GCS permission to support fileset operations [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1909900260


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   Can't come up with a better one, let 's work on improving it later.



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more permission to support fileset operations [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1906718286


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)

Review Comment:
   Why do we only need to handle `readExpressions`, what about `writeExpressions`?



##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   What's the real cause of this issue? I recall that you used the prefix match mode to control permission. Why can't it work?
   
   When I worked on GCS IAM authorization, I tested if using the prefix condition on a role, I worked, so I wonder if there is any difference in credentials. 



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more GCS permission to support fileset operations [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1908100547


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   Yes, I have used PySpark to test the privileges. 



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more GCS permission to support fileset operations [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1908232299


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   Could you provide the detailed privileges?



-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more permission to support fileset operations [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#issuecomment-2576873917

   @jerryshao @yuqi1129 , PTAL


-- 
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: commits-unsubscribe@gravitino.apache.org

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


Re: [PR] [#6054] feat(core): add more permission to support fileset operations [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #6141:
URL: https://github.com/apache/gravitino/pull/6141#discussion_r1906873510


##########
bundles/gcp/src/main/java/org/apache/gravitino/gcs/credential/GCSTokenProvider.java:
##########
@@ -99,6 +101,57 @@ private AccessToken getToken(Set<String> readLocations, Set<String> writeLocatio
     return downscopedCredentials.refreshAccessToken();
   }
 
+  private List<String> getReadExpressions(String bucketName, String resourcePath) {
+    List<String> readExpressions = new ArrayList<>();
+    readExpressions.add(
+        String.format(
+            "resource.name.startsWith('projects/_/buckets/%s/objects/%s')",
+            bucketName, resourcePath));
+    getAllResources(resourcePath)
+        .forEach(
+            parentResourcePath ->
+                readExpressions.add(
+                    String.format(
+                        "resource.name == 'projects/_/buckets/%s/objects/%s'",
+                        bucketName, parentResourcePath)));
+    return readExpressions;
+  }
+
+  @VisibleForTesting
+  // "a/b/c" will get ["a", "a/", "a/b", "a/b/", "a/b/c"]
+  static List<String> getAllResources(String resourcePath) {

Review Comment:
   I gave the user the list object privileges for the bucket and read permission for the exact path, then the user will got the privileges.
   
   <img width="1668" alt="image" src="https://github.com/user-attachments/assets/071777b5-f55b-46b0-b842-f4beedbf9123" />
   
   
   The following is the result:
   
   **Can't list objects in the bucket root**
   <img width="1665" alt="image" src="https://github.com/user-attachments/assets/e0ed0307-708c-4185-9294-022690940d43" />
   
   **Can't list objects in the xiaoyu123/gcs_catalog_with_organization**
   <img width="1423" alt="image" src="https://github.com/user-attachments/assets/b1d6486c-a81a-451d-9f03-690f1a97d250" />
   
   **Can't list objects in the xiaoyu123/gcs_catalog_with_organization/schema**
   <img width="1622" alt="image" src="https://github.com/user-attachments/assets/1a12ddf3-687a-479e-9b65-71a41b472fe2" />
   
   **Can list objects in the xiaoyu123/gcs_catalog_with_organization/schema/example**
   <img width="1471" alt="image" src="https://github.com/user-attachments/assets/bc890c12-6f77-4599-a3ad-692ce204511e" />
   
   **Can list objects in the xiaoyu123/gcs_catalog_with_organization/schema/example/people**
   <img width="1560" alt="image" src="https://github.com/user-attachments/assets/c5c599df-9509-44aa-9096-200a7d904f18" />



-- 
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: commits-unsubscribe@gravitino.apache.org

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