Skip to content

fix(s3): cache the identity remote signing signs with - #2170

Merged
c-thiel merged 4 commits into
mainfrom
fix/s3-signing-identity-cache
Oct 25, 2026
Merged

c-thiel merged 4 commits into
mainfrom
fix/s3-signing-identity-cache

Conversation

@c-thiel

@c-thiel c-thiel commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Summary

With an assumed role or the system identity, every S3 sign request called STS (and the base credential provider) again: signing asks the credential provider directly, and the SDK's AssumeRoleProvider does not cache. One sign request per engine S3 request meant one or two STS calls per S3 request.

 sign request
   get_signing_identity
+    static keys ──► load (no network call)
+    assume-role / system identity ──► S3_SIGNING_IDENTITY_CACHE (key: profile + credential)
       load: AssumeRole / system identity ──► Identity
  • The identity is cached for half its remaining lifetime, at most 1 hour, like vended credentials.
  • The key hashes the full storage profile and the full credential (role, external ID, secrets, endpoints, region, tags), the same context the vended-credentials cache uses.
  • Concurrent misses share one load; errors are not cached.
  • LAKEKEEPER__CACHE__STC__ENABLED and __CAPACITY apply to this cache too.

Evidence

  • Before: 3 sign lookups with an assumed role → 3 AssumeRole calls (local STS mock).
    After: 1 call. A different external ID → its own call; the test fails if the credential is left out of the key.
  • Real-AWS signing tests with and without an assumed role pass.

Merge Danger

Door: two-way. No stored data changes.

Blast Radius: S3 remote signing.

  • A revoked role session or a changed trust policy takes effect for signing when the cached identity expires (at most 1 hour), as it already does for vended credentials.

Release notes

Bug Fixes

  • Remote signing no longer calls STS for every request. With an assumed role or the system identity, Lakekeeper reuses the credentials it signs with until half their lifetime has passed.

Summary by CodeRabbit

  • New Features
    • S3 signing identities used with role assumption or system identity credentials are cached for reuse. Entries are separated by storage and credential context and expire according to identity validity, with a fallback when no expiration is provided. Static access keys without an assumed role bypass this cache.
  • Documentation
    • Updated the credentials-cache guide to cover S3 signing credentials and explain that each cache has its own capacity limit.
    • Documented s3_signing_identity as a cache type for monitoring.

With an assumed role or the system identity, every sign request called STS (and the base credential provider) again, because signing asks the credential provider directly. The identity is now cached per storage profile and credential for half its lifetime, at most one hour, in the short-term credentials cache. Static keys stay uncached.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4150f5f7-13c7-4ddc-b75f-7499e8e62a50
Commits

Reviewing files that changed from the base of the PR and between 4fbff11 and dbbc3c6.

Files selected for processing: 1
  • crates/lakekeeper/src/service/storage/s3.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

The shared credential cache now supports generic keys and cache types. S3 signing identities obtained through role assumption or system identity loading use a separate cache, keyed by storage context and credential. Azure, GCS, and S3 short-term credential lookups identify their cache type.

Changes

Credential cache updates

Layer / File(s) Summary
Generalized cache foundation
crates/lakekeeper/src/service/storage/cache.rs
The shared cache utilities support generic keys and cache types. The storage-context key supports the S3 signing identity cache. Metrics report sizes for the short-term credential caches and the signing identity cache.
S3 signing identity integration and tests
crates/lakekeeper/src/service/storage/s3.rs
S3 signing identity lookup bypasses caching for credentials that do not assume a role and are not AWS system identities. Other identities use the cache. Tests cover reuse, expiration, static identity validity, and separate loads for different external IDs.
Provider cache labeling and documentation
crates/lakekeeper/src/service/storage/az/mod.rs, crates/lakekeeper/src/service/storage/gcs/mod.rs, crates/lakekeeper/src/service/storage/s3.rs, docs/docs/configuration.md, docs/docs/monitoring.md, crates/lakekeeper/src/service/cache_metrics.rs
Azure, GCS, and S3 short-term credential lookups pass the ShortTermCredentials cache type. The documentation describes the S3 signing cache, per-cache capacity, and cache metric types.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant S3Profile
  participant SigningIdentityCache
  participant STS
  S3Profile->>SigningIdentityCache: Look up identity by storage context and credential
  SigningIdentityCache->>STS: Load identity on cache miss
  STS-->>SigningIdentityCache: Return identity
  SigningIdentityCache-->>S3Profile: Return signing identity
Loading

Possibly related PRs

  • lakekeeper/lakekeeper#2174: Centralizes S3 system-identity validation in SDK configuration and signing paths, which is relevant to cached identities.
  • lakekeeper/lakekeeper#2165: Adds lazy identity caching for assume-role credentials used by S3 SDK storage clients; this PR caches identities used by S3 remote signing.

Suggested reviewers: brgr-s

Merge Risk: Minimal · up to dbbc3

No actionable merge-blocking issue is established from the supplied evidence; normal validation remains appropriate.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 48.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: caching the identity used for S3 remote signing. It is specific and related to the pull request objectives, despite awkward wording.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the cache at night,
A signing identity stays in sight.
With role or system keys in play,
The cache recalls them on the way.
Expiry marks when they depart,
And fresh requests can make a start.

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 24, 2026
The cache of signing identities reports hits, misses and size as `s3_signing_identity`, so signing traffic does not hide the hit rate of the vended-credentials cache. Comments and docs describe the cache as it is.
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 24, 2026
System-identity keys without an expiry (from the environment or a credentials file) are cached for five minutes, so concurrent sign requests do not wait for each other to load them. Docs name the signing cache as a separate cache and list its metric type.
@c-thiel
c-thiel force-pushed the fix/s3-signing-identity-cache branch from 81759d2 to 4fbff11 Compare October 24, 2026 11:20
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@c-thiel
c-thiel merged commit 6eb29c5 into main Oct 25, 2026
85 of 87 checks passed
@c-thiel
c-thiel deleted the fix/s3-signing-identity-cache branch October 25, 2026 08:20
c-thiel added a commit that referenced this pull request Oct 25, 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.

1 participant