You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "XJDKC (via GitHub)" <gi...@apache.org> on 2025/03/17 21:16:42 UTC

[PR] Fix updating the storage config [polaris]

XJDKC opened a new pull request, #1191:
URL: https://github.com/apache/polaris/pull/1191

   <!--
       Possible security vulnerabilities: STOP here and contact security@apache.org instead!
   
       Please update the title of the PR with a meaningful message - do not leave it "empty" or "generated"
       Please update this summary field:
   
       The summary should cover these topics, if applicable:
       * the motivation for the change
       * a description of the status quo, for example the current behavior
       * the desired behavior
       * etc
   
       PR checklist:
       - Do a self-review of your code before opening a pull request
       - Make sure that there's good test coverage for the changes included in this PR
       - Run tests locally before pushing a PR (./gradlew check)
       - Code should have comments where applicable. Particularly hard-to-understand
         areas deserve good in-line documentation.
       - Include changes and enhancements to the documentation (in site/content/in-dev/unreleased)
       - For Work In Progress Pull Requests, please use the Draft PR feature.
   
       Make sure to add the information BELOW this comment.
       Everything in this comment will NOT be added to the PR description.
   -->
   For Storage Config, some properties are automatically provided by the Polaris service. For example:
   * S3
       * `externalId`: if users don't provide an external id, polaris will generate one for users, and it's not alterable
       * `userARN`: this user ARN represent the identity of the polaris service and it's provided by polaris.
   * Azure
       * `consentUrl`: this url is used to authorize polaris service for accessing user-provided storage account, which is generated by polaris service
       * `multiTanantAppName`: Name of the client application created for user's storage account. User need to grant this application permission to obtain an access token on the allowed storage location.
    * GCP
      * `gcsServiceAccount`: The GCS service account that represents polaris service.
   
   When creating a catalog, users don’t need to provide these properties, Polaris sets them automatically and stores them in the storage config. To retrieve these details, users must send a GET request after the catalog is created.
   
   For catalog updates, users also don’t need to include these properties in the `UpdateCatalogRequest`. This request contains a new storage configuration that does not include the service-provided properties. Previously, we simply replaced the existing storage configuration (which contained these properties) with the new one, unintentionally removing them from the catalog entity.
   
   This PR fixes the issue by ensuring that the existing service-provided properties are inherited when updating the catalog.


-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2006144562


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   `userARN` represents the polaris service, from my understanding, it should be configured by the polaris service provider rather than the user.
   
   The owner of the catalog is an user, user only needs to provide an IAM role, polaris service will use its AWS credential (the `userARN`) to assume the role and get the temp AWS credential. How could an user provide an AWS user ARN for polaris service? 
   
   Also, for the current implementation, we completely ignore the `userARN` during the catalog creation, see:
   1. https://github.com/apache/polaris/blob/a1e9d8a14d45519bf3cfbdcad01e9ec8167c5d3c/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java#L81-L97
   2. https://github.com/apache/polaris/blob/a1e9d8a14d45519bf3cfbdcad01e9ec8167c5d3c/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java#L244-L255
   This also shows that `userARN` can't be modify by users since it's a fixed value provided by polaris service itself.
   
   Here is the guidance from Open Catalog for creating a catalog: https://other-docs.snowflake.com/en/opencatalog/create-catalog
   The entire flow is:
   1. User/Catalog Owner creates an IAM role, this role needs to have access to the S3 bucket
   4. User/Catalog Owner creates a Polaris Catalog and provides this IAM role
   5. User/Catalog Owner can get the `userARN` info provided by Polaris Service by sending a getCatalog request
   6. User adds the userARN into the trust relationship of that IAM role so that Polaris service can assume the IAM role provided by the user.
   7. Polaris uses its AWS credential (`userARN`) to assume the IAM role and get temp AWS credential, this AWS credential can be used to access the storage 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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2006144562


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   `userARN` represents the polaris service, from my understanding, it should be configured by the polaris service provider rather than the user.
   
   The owner of the catalog is an user, user only needs to provide an IAM role, polaris service will use its AWS credential (the `userARN`) to assume the role and get the temp AWS credential. How could an user provide an AWS user ARN for polaris service?
   
   Here is the guidance from Open Catalog for creating a catalog: https://other-docs.snowflake.com/en/opencatalog/create-catalog
   The entire flow is:
   1. User/Catalog Owner creates an IAM role, this role needs to have access to the S3 bucket
   2. User/Catalog Owner creates a Polaris Catalog and provides this IAM role
   3. User/Catalog Owner can get the `userARN` info provided by Polaris Service by sending a getCatalog request
   4. User adds the userARN into the trust relationship of that IAM role so that Polaris service can assume the IAM role provided by the user.
   5. Polaris uses its AWS credential (`userARN`) to assume the IAM role and get temp AWS credential, this AWS credential can be used to access the storage 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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2006160060


##########
polaris-core/src/main/java/org/apache/polaris/core/storage/FileStorageConfigurationInfo.java:
##########
@@ -53,4 +54,15 @@ public void validatePrefixForStorageType(String loc) {
               "Location prefix not allowed: '%s', expected prefix: file:// or / or *", loc));
     }
   }
+
+  public @Nonnull FileStorageConfigurationInfo merge(@Nonnull FileStorageConfigurationInfo other) {
+    if (other.getStorageType() != this.getStorageType()) {
+      throw new IllegalArgumentException(
+          String.format(
+              "Storage type mismatch: %s vs %s", this.getStorageType(), other.getStorageType()));
+    }

Review Comment:
   Thanks for the suggestion, will revise my PR with `Preconditions`.



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2032029644


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   Thanks Dmitri!
   
   > Then it should not be stored in catalog properties at all, IMHO
   
   First, this is an existing behavior, so we can't migrate away from directly. 
   Right now, `userArn` is provided by polaris itself and stored in catalog properties when creating the catalog. If we don't store it in catalog properties, when loading the catalog entities, we need to dynamically inject the `userArn` info so that it can be included in the `loadCatalog` response. Users need this info since they need to add this `userArn` in the trust relationship of their AWS IAM role, in this way polaris can use the corresponding aws credential of the `userArn` to assume the IAM role.
   
   > using catalog-level `userArn`
   
   Creating one `userArn` for each catalog is very expensive (an user arn means a real AWS user and an AWS credential), instead of relying on different `userArn`, users should use `externalID` if they only want their IAM role to be assumed by polaris for a specific catalog. 
   I will open a thread in `dev` ML, let's discuss on the thread!



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1191:
URL: https://github.com/apache/polaris/pull/1191#issuecomment-2864885470

   This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.


-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2029582960


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   I think this opens a can of worms :)
   
   From the OSS perspective I can imagine users of Apache Polaris, who may want to have one service, but use different `userArn` for different catalogs. 
   
   Ultimately, it depends on the scope of control the catalog owner has and the service owner has. Deployment scenarios can vary vastly.
   
   I'd propose to cover this by a feature flag (using service-level `userArn` or catalog-level)... but it might be best to discuss this on the `dev` ML.



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2006353669


##########
polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java:
##########
@@ -240,6 +246,21 @@ public Builder setStorageConfigurationInfo(
         }
         allowedLocations.add(defaultBaseLocation);
         validateMaxAllowedLocations(allowedLocations);
+
+        PolarisStorageConfigurationInfo existingConfig = null;

Review Comment:
   The logic is currently in the CatalogEntity builder, for the builder, it doesn't have the catalog entity but just an internalProperties map. I'm trying to get the storage config from the internal properties map. Do you mean I need to implement a method like this:
   
   ```java
   class CatalogDao {
     PolarisStorageConfigurationInfo getExistingStorageConfig(Map<String, String> internalProperties) {
     }
   }
   ```



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on PR #1191:
URL: https://github.com/apache/polaris/pull/1191#issuecomment-2734130935

   > This change adds even more higher-level concerns into persistence related code.
   > 
   > We already have hard dependencies from persistence code to object-storage specifics. I'm -1 on adding more object-storage specific/related complexity to this code.
   
   


-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2004515618


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   Why?
   
   A Polaris Admin should have control over any configuration. `userARN` is ultimately controlled by the owner of the catalog and corresponding storage. Why would Polaris code prevent changes to these values?



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2032053465


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   From an Apache Polaris user perspective, I do not really see how `userArn` affects the behaviour of Polaris (see also my more specific comment below).
   
   Overall, it looks like this area of functionality may need a review :thinking: 



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2006144562


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   `userARN` represents the polaris service, from my understanding, it should be configured by the polaris service provider rather than the user.
   
   The owner of the catalog is an user, user only needs to provide an IAM role, polaris service will use its AWS credential (the `userARN`) to assume the role and get the temp AWS credential. How could an user provide an AWS user ARN for polaris service?
   
   Here is the guidance from Open Catalog for creating a catalog: https://other-docs.snowflake.com/en/opencatalog/create-catalog



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "MonkeyCanCode (via GitHub)" <gi...@apache.org>.
MonkeyCanCode closed pull request #1191: Fix updating the storage config
URL: https://github.com/apache/polaris/pull/1191


-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2029580267


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   > userARN represents the polaris service [...]
   
   Then it should not be stored in catalog properties at all, IMHO.



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2032050426


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null

Review Comment:
   I could not find where `userArn` is used by the Polaris Server. Could you point me at the code where the configuration is used?



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC closed pull request #1191: Fix updating the storage config
URL: https://github.com/apache/polaris/pull/1191


-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2006353669


##########
polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java:
##########
@@ -240,6 +246,21 @@ public Builder setStorageConfigurationInfo(
         }
         allowedLocations.add(defaultBaseLocation);
         validateMaxAllowedLocations(allowedLocations);
+
+        PolarisStorageConfigurationInfo existingConfig = null;

Review Comment:
   The logic is currently in the CatalogEntity builder, for the builder, it doesn't have the catalog entity but just an internalProperties map. I'm trying to get the storage config from the internal properties map. Do you mean I need to implement a method like this:
   
   ```java
   class CatalogDao {
     PolarisStorageConfigurationInfo getExistingStorageConfig(Map<String, String> internalProperties) {
     }
   }
   ```
   
   Or it's better to just put it in the CatalogEntity class as a static method?



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2000802932


##########
polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java:
##########
@@ -205,6 +205,7 @@ public Builder() {
 
     public Builder(CatalogEntity original) {
       super(original);
+      original.getStorageConfigurationInfo();

Review Comment:
   That's a noop?



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2006144562


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   `userARN` represents the polaris service, from my understanding, it should be configured by the polaris service provider rather than the user.
   
   The owner of the catalog is an user, user only needs to provide an IAM role, polaris service will use its AWS credential (the `userARN`) to assume the role and get the temp AWS credential. How could an user provide an AWS user ARN for polaris service? 
   
   Also, for the current implementation, we completely ignore the `userARN` during the catalog creation, see:
   1. https://github.com/apache/polaris/blob/a1e9d8a14d45519bf3cfbdcad01e9ec8167c5d3c/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java#L81-L97
   2. https://github.com/apache/polaris/blob/a1e9d8a14d45519bf3cfbdcad01e9ec8167c5d3c/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java#L244-L255
   This also shows that `userARN` shouldn't be provided by users and can't be modify by users since it's a fixed value provided by polaris service itself.
   
   Here is the guidance from Open Catalog for creating a catalog: https://other-docs.snowflake.com/en/opencatalog/create-catalog
   The entire flow is:
   1. User/Catalog Owner creates an IAM role, this role needs to have access to the S3 bucket
   4. User/Catalog Owner creates a Polaris Catalog and provides this IAM role
   5. User/Catalog Owner can get the `userARN` info provided by Polaris Service by sending a getCatalog request
   6. User adds the userARN into the trust relationship of that IAM role so that Polaris service can assume the IAM role provided by the user.
   7. Polaris uses its AWS credential (`userARN`) to assume the IAM role and get temp AWS credential, this AWS credential can be used to access the storage 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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2004468505


##########
polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java:
##########
@@ -240,6 +246,21 @@ public Builder setStorageConfigurationInfo(
         }
         allowedLocations.add(defaultBaseLocation);
         validateMaxAllowedLocations(allowedLocations);
+
+        PolarisStorageConfigurationInfo existingConfig = null;

Review Comment:
   Agreed. It'd be nice the logic was wrapped in a DAO method like `CatalogDao::GetExistingStorageConfig()`



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2032029644


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   Thanks Dmitri! Creating one `userArn` for each catalog is very expensive (an user arn means a real AWS user and a AWS credential), instead of relying on different `userArn`, users should use `externalID` if they only want their IAM role to be assumed by polaris for a specific catalog. 
   I will open a thread in `dev` ML, let's discuss on the thread!



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2004474260


##########
polaris-core/src/main/java/org/apache/polaris/core/storage/FileStorageConfigurationInfo.java:
##########
@@ -53,4 +54,15 @@ public void validatePrefixForStorageType(String loc) {
               "Location prefix not allowed: '%s', expected prefix: file:// or / or *", loc));
     }
   }
+
+  public @Nonnull FileStorageConfigurationInfo merge(@Nonnull FileStorageConfigurationInfo other) {
+    if (other.getStorageType() != this.getStorageType()) {
+      throw new IllegalArgumentException(
+          String.format(
+              "Storage type mismatch: %s vs %s", this.getStorageType(), other.getStorageType()));
+    }

Review Comment:
   Minor: we could use precondition here.
   ```
       Preconditions.checkArgument(other.getStorageType() == this.getStorageType(),
             String.format(
                 "Storage type mismatch: %s vs %s", this.getStorageType(), other.getStorageType()));
   ```



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on PR #1191:
URL: https://github.com/apache/polaris/pull/1191#issuecomment-2734138043

   > This change adds even more higher-level concerns into persistence related code.
   > 
   > We already have hard dependencies from persistence code to object-storage specifics. I'm -1 on adding more object-storage specific/related complexity to this code.
   
   Hey @snazy, thanks for the review! Are you saying the changes to the storage configuration classes? We are move these code into different classes.


-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2001587260


##########
polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java:
##########
@@ -205,6 +205,7 @@ public Builder() {
 
     public Builder(CatalogEntity original) {
       super(original);
+      original.getStorageConfigurationInfo();

Review Comment:
   Yes, will remove it



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "eric-maynard (via GitHub)" <gi...@apache.org>.
eric-maynard commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2002437112


##########
polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java:
##########
@@ -240,6 +246,21 @@ public Builder setStorageConfigurationInfo(
         }
         allowedLocations.add(defaultBaseLocation);
         validateMaxAllowedLocations(allowedLocations);
+
+        PolarisStorageConfigurationInfo existingConfig = null;

Review Comment:
   @flyrain would the DAO be a better candidate place for this logic?



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "XJDKC (via GitHub)" <gi...@apache.org>.
XJDKC commented on code in PR #1191:
URL: https://github.com/apache/polaris/pull/1191#discussion_r2032029644


##########
service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -664,6 +665,15 @@ private void validateUpdateCatalogDiffOrThrow(
             "Cannot modify ExternalId in storage config from %s to %s",
             currentStorageConfig, newStorageConfig);
       }
+
+      if ((currentAwsConfig.getUserARN() != null
+              && !currentAwsConfig.getUserARN().equals(newAwsConfig.getUserARN()))
+          || (newAwsConfig.getUserARN() != null
+              && !newAwsConfig.getUserARN().equals(currentAwsConfig.getUserARN()))) {
+        throw new BadRequestException(
+            "Cannot modify userARN in storage config from %s to %s",

Review Comment:
   Thanks Dmitri!
   
   > Then it should not be stored in catalog properties at all, IMHO
   
   First, this is an existing behavior, so we can't migrate away from directly. 
   Right now, `userArn` is provided by polaris itself and stored in catalog properties when creating the catalog. If we don't store it in catalog properties, when loading the catalog entities, we need to dynamically inject the `userArn` info so that it can be included in the `loadCatalog` response. Users need this info since they need to add this `userArn` in the trust relationship of their AWS IAM role, in this way polaris can use the corresponding aws credential of the `userArn` to assume the IAM role.
   
   Creating one `userArn` for each catalog is very expensive (an user arn means a real AWS user and a AWS credential), instead of relying on different `userArn`, users should use `externalID` if they only want their IAM role to be assumed by polaris for a specific catalog. 
   I will open a thread in `dev` ML, let's discuss on the thread!



-- 
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: issues-unsubscribe@polaris.apache.org

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


Re: [PR] Fix updating the storage config [polaris]

Posted by "MonkeyCanCode (via GitHub)" <gi...@apache.org>.
MonkeyCanCode commented on PR #1191:
URL: https://github.com/apache/polaris/pull/1191#issuecomment-5153950784

   Close this one due to inactive.


-- 
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: issues-unsubscribe@polaris.apache.org

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