Repository navigation
core: Credential Vending Refactor - #3699
Conversation
| Supplier<StorageAccessConfig> loader) { | ||
| long maxCacheDurationMs = maxCacheDurationMs(realmConfig); | ||
| return cache | ||
| .get( |
There was a problem hiding this comment.
The Supplier in this .get method in Caffeine is supposed to be fast, but I believe in our case it may hit network (e.g. STS), which is not desirable... It might be best to go back to LoadingCache, which allows loaders to be blocking.
There was a problem hiding this comment.
I can revert, but I have to say my limited (ai-assisted) research convinced me that there's no point in using a LoadingCache with a dummy loader if you're always calling a get with an explicit loader. The behavior should be the same with either. might be wrong, though. happy to trust you on this.
There was a problem hiding this comment.
I agree, that the old code was using LoadingCache in a strange way... yet, I believe LoadingCache in itself is the right tool here 😅
There was a problem hiding this comment.
This is related to using the "key" as input for Storage Config generation. If we could achieve that, LoadingCache would fit naturally.
There was a problem hiding this comment.
I believe this comment thread still applies... WDYT?
There was a problem hiding this comment.
Don't you have a "chicken and egg" problem there? you need StorageIntegration for cache key first... Or do you mean we can create them twice effectively?
There was a problem hiding this comment.
Sorry, I do not see the "chicken", only the "egg" 😉 which is the key. It is created first, then we go through the cache, then the loader function takes the key, creates a light-weight AwsCredentialsStorageIntegration and feeds the data from the key into it.
There was a problem hiding this comment.
I took a shot at it. basically added a load method to the cache key interface. each key carries it's own loader method and that's what loader method of the LoadingCache is calling. let me know what you think.
There was a problem hiding this comment.
Sorry, not quite there yet from my POV 😅
So we derive storage config like this: entity -> PolarisStorageConfigurationInfo -> (1) PolarisStorageIntegration -> include CredentialVendingContext -> (cache) -> StorageAccessConfig
I believe we need to first combine PolarisStorageConfigurationInfo and CredentialVendingContext into a cache key. This requires (2) a concrete PolarisStorageIntegration (same as step 1 above). However, the key should only contain the data that acts as direct input into the config generation. So, it should not hold PolarisStorageIntegration. The cache loader function will re-derive (3) PolarisStorageIntegration from the cache key at load time (if it happens). This is a fast operation as far as I understand.
This is a fine point, I admit, but I think it is critical for caching correctness and indirectly for future improvement in this code.
There was a problem hiding this comment.
you're right, that was a poor implementation, I shouldn't have included integration itself as an aux. still I don't like the idea of re-deriving entire PolarisStorageIntegration object. the reason is that the first time it's instantiated, the point it to build a key, the second time around you build a credential. inputs for each are not necessarily identical, I changed session name derivation in AWS to highlight it. I switched to deriving session name during cache key generation and then simply using resolved string in the cache key directly. in other words, cache key generation needs entire CredentialVendingContext (which includes principal name), while credential compute needs only the session name string that's already resolved. Reinstantiating PolarisStorageIntegration with entire CredentialVendingContext is therefore wasteful.
I switched to providing fields like stsClientProvider and credentialResolver to cache key as aux fields instead of integration itself. the key then calls a static compute method on the integration which takes in only what it absolutely needs and params are coming from the fields in the cache key. let me know what you think.
|
@tokoko : it looks like this PR has a lot of conflicts now... CI will not run because of that 😅 |
|
@dimas-b that's fine, this one was more for you to take a look 😆 I'll take care of the conflicts and bunch of other stuff that's still unfinished |
|
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. |
|
@tokoko : The general approach in this PR is fine from my POV 👍 If you have time I think we can iterate. |
|
yeah, I'm gonna rebase and make it ready for a review this weekend. |
f7d7c81 to
9e185c0
Compare
dimas-b
left a comment
There was a problem hiding this comment.
I like the idea of using application-scoped beans for producing StorageAccessConfig in runtime.
Posting some preliminary comments below. I did not review every single line, but the general approach LGTM 👍
|
Thanks @tokoko for working on it. Is there a dev mailing thread for it? If not, I'd recommend to have one for better visibility. It is generally a good practice to engage with the community earlier to avoid last minute surprises. |
|
@flyrain : This PR was mentioned on the S3 Tables thread: https://lists.apache.org/thread/c5nc7144zlsb5vdjmpsgbc0h0g5no9c0 Do you think we need a separate discussion for this? |
|
@flyrain sure, I'll make a bit more changes, change PR description to be more accurate with latest changes and send out an email on the devlist. For me, the main goal of this PR is to demo the overall direction and build consensus on it. P.S. I'd be okay to split these changes up over a series of smaller PRs if people think that's more appropriate. |
ab1423f to
799f23b
Compare
# Conflicts: # persistence/nosql/persistence/metastore/src/main/java/org/apache/polaris/persistence/nosql/metastore/NoSqlMetaStore.java # persistence/nosql/persistence/metastore/src/main/java/org/apache/polaris/persistence/nosql/metastore/NoSqlMetaStoreManager.java # persistence/nosql/persistence/metastore/src/main/java/org/apache/polaris/persistence/nosql/metastore/NonFunctionalBasePersistence.java # polaris-core/src/main/java/org/apache/polaris/core/storage/gcp/GcpCredentialsStorageIntegration.java # polaris-core/src/test/java/org/apache/polaris/core/storage/aws/AwsCredentialsStorageIntegrationTest.java # polaris-core/src/test/java/org/apache/polaris/core/storage/gcp/GcpCredentialsStorageIntegrationTest.java
Two tests imported from main called the removed getSubscopedCreds(...) via a 2-arg constructor; rewrite them on the existing 3-arg test constructor and the generateStorageAccessConfig API.
dimas-b
left a comment
There was a problem hiding this comment.
LGTM overall 👍 Please fix conflicts 🙂
# Conflicts: # persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java # polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TreeMapTransactionalPersistenceImpl.java
dennishuo
left a comment
There was a problem hiding this comment.
Verified all the previous discussion points match what I had in mind, thanks!
|
I propose to merge tomorrow (hoping to not run into merge conflicts 😅 ) @flyrain : FYI, if you're interested |
StorageCredentialCacheby moving orchestration logic intoStorageAccessConfigProvider