Skip to content

core: Credential Vending Refactor - #3699

Merged
dimas-b merged 32 commits into
apache:mainfrom
tokoko:refactor-vending
Jun 5, 2026
Merged

dimas-b merged 32 commits into
apache:mainfrom
tokoko:refactor-vending

Conversation

@tokoko

@tokoko tokoko commented Feb 8, 2026 •

Copy link
Copy Markdown
Contributor
  • Decouples credential vending from StorageCredentialCache by moving orchestration logic into StorageAccessConfigProvider
  • Remove credential vending from MetaStoreManager: PolarisCredentialVendor interface, StorageCredentialsVendor, and getSubscopedCredsForEntity() implementations are removed from MetaStoreManager implementations. Credential vending no longer round-trips through the persistence layer.
  • Moves caching into storage integrations: Each PolarisStorageIntegration subclass now owns its StorageCredentialCache interaction and builds cloud-specific cache keys.
  • Simplify StorageAccessConfigProvider: Now directly resolves the storage integration and delegates to it, instead of going through StorageCredentialsVendor → PolarisCredentialVendor → MetaStoreManager → persistence layer → integration provider. Entity is no longer re-loaded from persistence during credential vending.

@dimas-b dimas-b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping this refactoring going, @tokoko !

From my POV this PR is moving in the right direction. I've got just a couple of relatively minor comments.

Supplier<StorageAccessConfig> loader) {
long maxCacheDurationMs = maxCacheDurationMs(realmConfig);
return cache
.get(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, that the old code was using LoadingCache in a strange way... yet, I believe LoadingCache in itself is the right tool here 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to using the "key" as input for Storage Config generation. If we could achieve that, LoadingCache would fit naturally.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this comment thread still applies... WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@dimas-b dimas-b May 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dimas-b

dimas-b commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

@tokoko : it looks like this PR has a lot of conflicts now... CI will not run because of that 😅

@tokoko

tokoko commented Feb 17, 2026

Copy link
Copy Markdown
Contributor Author

@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

@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale label Mar 20, 2026
@dimas-b

dimas-b commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

@tokoko : The general approach in this PR is fine from my POV 👍 If you have time I think we can iterate.

@tokoko

tokoko commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

yeah, I'm gonna rebase and make it ready for a review this weekend.

@dimas-b dimas-b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👍

@flyrain

flyrain commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

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.

@dimas-b

dimas-b commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

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

@tokoko

tokoko commented Mar 26, 2026

Copy link
Copy Markdown
Contributor Author

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

@tokoko
tokoko force-pushed the refactor-vending branch from ab1423f to 799f23b Compare March 27, 2026 23:43
tokoko added 7 commits May 8, 2026 09:18
# 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 dimas-b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall 👍 Please fix conflicts 🙂

tokoko added 3 commits May 14, 2026 16:54
# 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
@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jun 2, 2026
@dimas-b
dimas-b requested review from dennishuo and flyrain June 2, 2026 22:38

@dennishuo dennishuo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified all the previous discussion points match what I had in mind, thanks!

@dimas-b

dimas-b commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

I propose to merge tomorrow (hoping to not run into merge conflicts 😅 )

@flyrain : FYI, if you're interested

@flyrain flyrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @tokoko for authoring. Thanks everyone for the review.

@dimas-b
dimas-b merged commit 005e889 into apache:main Jun 5, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants