Skip to content

IRC: Optimize Credential Vending - #3997

Merged
singhpk234 merged 7 commits into
apache:mainfrom
singhpk234:optimize/cred-vending
Apr 7, 2026
Merged

singhpk234 merged 7 commits into
apache:mainfrom
singhpk234:optimize/cred-vending

Conversation

@singhpk234

@singhpk234 singhpk234 commented Mar 14, 2026 •

Copy link
Copy Markdown
Contributor

About the change

The /credentials endpoint currently performs a full table metadata read from object storage to vend credentials.
This is expensive and unnecessary — the table locations needed for credential vending are already available in the
entity's internal properties stored in the metastore.

This PR introduces an optimized credential vending path via loadCredentials that reads locations directly from the
metastore, avoiding the object storage round-trip. When the entity lacks the required internal properties (e.g. tables
created before the property was stored), it gracefully falls back to the existing loadTableWithAccessDelegation path.

The optimization is restricted to native Polaris catalogs only — federated/external catalogs fall back to the standard
path since their entity internal properties may not be in sync with the remote catalog's actual table metadata.

Key changes:

  • New loadCredentials method in IcebergCatalogHandler that reads locations from entity internal properties
  • Falls back to full loadTableWithAccessDelegation when: entity lacks location properties, or catalog is external/federated
  • Fails fast with NoSuchTableException if the entity is not found in the metastore
  • Authorization tests include both positive and negative privilege cases

co-author : @adutra

Checklist

  • 🛡️ Don't disclose security issues! (contact [email protected])
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed) --later
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Mar 14, 2026
@sfc-gh-prsingh
sfc-gh-prsingh force-pushed the optimize/cred-vending branch 2 times, most recently from eb5db50 to f802657 Compare March 14, 2026 08:19
@singhpk234
singhpk234 marked this pull request as ready for review March 18, 2026 14:56
* full table metadata read from object storage. Falls back to the standard
* loadTableWithAccessDelegation path if the entity lacks the required properties.
*/
public ImmutableLoadCredentialsResponse loadCredentialsFromEntityProperties(

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.

Do we need to also check the validateRemoteTableLocations when reading from props?

This seems important since the allowed locations can occur outside of a table write where the location is currently checked.

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 wonder if we should even allow RemoteCatalog aka External Catalogs ? external writes can happen independently of the external catalog without going through Polaris and our entities might not be consistent ?

I added a check for now to only do this for catlaog owned by Polaris

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

Sorry about the delay, @singhpk234 , I think I stated reviewing this PR a while back, but got distracted 😅

Adding some minor comments, but I think @travis-bowen raised some good points.

@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, I'll make another pass tomorrow

@flyrain

flyrain commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Thanks a lot for adding this, @singhpk234! I think it will skip the IO for the credential endpoint, which saves a lot, in terms of cost and time. Great idea!

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

flyrain
flyrain previously approved these changes Mar 30, 2026

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

+1 Thanks @singhpk234 !

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Mar 30, 2026
@singhpk234
singhpk234 requested a review from dimas-b March 31, 2026 17:56
@dimas-b

dimas-b commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

@singhpk234 : please update PR description to match the latest state of the code :)

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

Sorry, one more last minute comment 😅

Add an OPTIMIZED_CREDENTIAL_VENDING feature flag that allows the
loadCredentials endpoint to vend storage credentials using location
data stored in entity internal properties, bypassing the expensive
full table metadata read from object storage.

When the flag is enabled, the new loadCredentialsFromEntityProperties
path resolves the table's base and data locations directly from the
metastore and uses them to scope credentials. If the entity or its
location data is missing (e.g. external catalogs or pre-apache#3226 data),
it falls back transparently to the standard loadTableWithAccessDelegation
path.
- Add authz test for loadCredentialsFromEntityProperties verifying
  TABLE_READ_DATA and TABLE_WRITE_DATA privileges
- Add integration tests for /loadCredentials endpoint with optimized
  credential vending both enabled and disabled
- Add loadCredentials helper method to CatalogApi
- Remove Javadoc from private vendCredentials method
…talogs, add negative authz tests

Remove the OPTIMIZED_CREDENTIAL_VENDING feature flag since the optimized
path already has robust fallback to the standard loadTable path. The adapter
now unconditionally calls loadCredentialsFromEntityProperties which handles
all edge cases internally.

Add an explicit guard to restrict optimized credential vending to native
Polaris catalogs only, since federated/external catalogs are passthrough
and their entity internal properties may not be in sync with the remote
catalog's actual table metadata.

Add negative authorization test cases to verify that TABLE_READ_PROPERTIES
and TABLE_WRITE_PROPERTIES are insufficient for credential vending.
Move the native catalog guard after authorizeLoadTable() since
baseCatalog is lazily initialized during authorization. Add two tests:
one verifying the optimized path never calls loadTable (no FileIO),
and one verifying non-IcebergCatalog triggers the fallback path.
…l fast on missing entity

Address flyrain's review feedback:
- Rename method since it can fall back to table metadata.json
- Throw NoSuchTableException instead of falling back when entity
  is not found in the metastore
…dentials

When vendCredentials returns null, use an empty StorageAccessConfig
instead of returning an empty response. This ensures the
supportsCredentialVending validation check runs on all code paths,
preventing silent masking of configuration errors.
@singhpk234
singhpk234 force-pushed the optimize/cred-vending branch from 058a695 to 15bc7ef Compare April 6, 2026 23:28
…alogFactory

Update test references to use renamed LocalCatalogFactory interface
and createCatalog method after upstream rename.
@singhpk234
singhpk234 requested review from dimas-b and flyrain April 7, 2026 01:00
@singhpk234
singhpk234 merged commit 671f538 into apache:main Apr 7, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Apr 7, 2026
@singhpk234

Copy link
Copy Markdown
Contributor Author

Thanks for review @dimas-b @flyrain !

dimas-b added a commit to dimas-b/polaris that referenced this pull request Apr 8, 2026
Fix method parameters that got skewed due to overlapped
merges of apache#3750 and apache#3997
dimas-b added a commit that referenced this pull request Apr 8, 2026
Fix method parameters that got skewed due to overlapped
merges of #3750 and #3997
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