HonahX commented on code in PR #2736: URL: https://github.com/apache/polaris/pull/2736#discussion_r2409029031
########## runtime/service/src/main/java/org/apache/polaris/service/catalog/io/AccessConfigProvider.java: ########## @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.catalog.io; + +import jakarta.annotation.Nonnull; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import java.util.Optional; +import java.util.Set; +import org.apache.iceberg.TableMetadata; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.polaris.core.context.CallContext; +import org.apache.polaris.core.entity.PolarisEntity; +import org.apache.polaris.core.persistence.MetaStoreManagerFactory; +import org.apache.polaris.core.persistence.PolarisResolvedPathWrapper; +import org.apache.polaris.core.storage.AccessConfig; +import org.apache.polaris.core.storage.PolarisStorageActions; +import org.apache.polaris.core.storage.StorageUtil; +import org.apache.polaris.core.storage.cache.StorageCredentialCache; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides temporary, scoped credentials for accessing table data in object storage (S3, GCS, Azure + * Blob Storage). + * + * <p>This provider decouples credential vending from catalog implementations, and should be the + * primary entrypoint to get sub-scoped credentials for accessing table data. + */ +@ApplicationScoped Review Comment: > I'm proposing to take loadPolarisStorageIntegration() out of the "metastore" code and have a separate interface for it I am +1 on the direction and indeed I am +1 on taking the whole getSubscopedCredential logic out of metastore as @XJDKC pointed out here: https://github.com/apache/polaris/pull/2759#discussion_r2407346953 However, given that this may incur more api change/deprecation at the persistence level, how about separating this to the follow-up PR. The current PR is already not small since it removes an interface : ) On the part about > from my POV the awkwardness is in mixing application-scoped code with CallContext — I think we might be viewing the pattern from slightly different angles. To me, having the class `@ApplicationScoped` simply implies that it’s stateless — which still holds true here since it only depends on two other application-scoped beans (`storageCredentialCache` and `metastoreManagerFactory`). Having `CallContext` as a method parameter doesn’t really break that statelessness; it’s just part of the request-level data flow, similar to other parameters like `identifier`, `metadata`, or `resolvedPath` that get resolved as the request progresses. We actually follow a similar pattern in a few other provider/factory classes as well. Conceptually, I think the distinction comes down to whether we want `getAccessConfig` to ever depend on request-scoped context — e.g., `CallContext`, `RealmContext`, or `RealmConfig`. If we foresee passing through any feature configuration that’s derived from a request, we’ll eventually need a way to accommodate those request-scoped inputs anyway. This, IMHO, is part of the reason that we pass in `CallContext` to `loadPolarisStorageIntegration` even though currently we are not using it. Curious on your thoughts on this? -- 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]
