Skip to content

[Server] Vend credentials for S3-compatible storage - #2172

Merged
yili-db merged 1 commit into
unitycatalog:mainfrom
yili-db:stack/s3compat_vending
Nov 17, 2026
Merged

yili-db merged 1 commit into
unitycatalog:mainfrom
yili-db:stack/s3compat_vending

Conversation

@yili-db

@yili-db yili-db commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


Part of a stack adding experimental S3-compatible storage (MinIO, Ceph, SeaweedFS, RustFS, Garage): #2170 (merged) to #2175, then #2169. Each PR builds on the one before it; the files changed since the previous PR are under the link above.

Description of changes

Credential vending for paths whose external location uses an s3_compatible credential.

  • With assume_role: AssumeRole at sts_endpoint, or at s3_endpoint when none is set, signed with the credential's key pair, with the session policy scoped to the path (without the KMS statement)

    • each AssumeRole call, with retries, is capped at 30 seconds
    • on shutdown, after the server drained its requests, it closes every STS client the AWS vendor built (AwsCredentialVendor and CloudCredentialVendor are AutoCloseable): the master role's and each bucket's at once, and a vend that would build one of those after the close gets UNAVAILABLE; the S3-compatible ones once the calls using them finish, and a call after the close uses a client of its own
    • a failed client close, of a shared or a one-off client, is logged rather than replacing a call's result
    • an STS client without configured keys gets a DefaultCredentialsProvider of its own, since closing a client closes its provider, and DefaultCredentialsProvider.create() returns one shared by every AWS client in the JVM
    • one STS client per STS endpoint and signing region, holding no keys: each AssumeRole is signed with the key pair of the credential version the request read, so updates close no client in use and no client keeps a key pair; at most 100 are kept, and an evicted one closes after the calls using it (SharedStsGenerator); a call whose client was evicted twice uses one of its own
  • Without assume_role, server.s3-compatible-storage.static-key-vending decides what clients get:

    • endpoint-only (default): the endpoint and region, no keys; engines use their own
    • static-key: the key pair, with an hour after which clients fetch again
    • the server's own access always gets the key pair; the secret is loaded only when keys are returned
  • S3BucketRegions reads the bucket's region from an anonymous HeadBucket, one lookup per bucket at a time, and caches a reported region

    • otherwise the default us-east-1 is used, and the storage is asked again after 30 seconds on a failure, or 5 minutes on an answer without a region; the region is part of the vend cache key, so a region reported later gets its own entry
    • a reported region is asked again after an hour, and at most 10,000 buckets are kept; a failed recheck keeps the reported region, while a 404 or an answer without a region drops it
    • while one request rechecks a region past its lifetime, others get the region reported before; only a bucket without one waits
    • the lookup owner checks the caches again before asking the storage, and any failure of the lookup backs off and completes it for its waiters
    • a blank or malformed region header counts as none; a recheck refused without the header, or with a blank one, keeps the reported region
  • The feature flag is checked before the region lookup, so a disabled feature never contacts the storage

  • CachingCloudCredentialVendor keys on a fingerprint of the stored credential, the endpoint and region, and, for s3_compatible only, server vs client access

  • FileOperationsImpl reads and writes Iceberg metadata on S3-compatible storage

  • DeltaCredentialsMapper sets s3.endpoint and client.region; the Iceberg REST config also sets s3.path-style-access, which that protocol defines

  • CloudCredentialVendorTest.testS3CompatibleStsFailureReturnsGeneralError: a failed AssumeRole on S3-compatible STS returns [Server] Return a general error when the server's storage or STS calls fail #2176's general error

  • An endpoint-only vend to a client carries an expiration an hour ahead, as a static-key one does, so clients that fetch again pick up a changed endpoint; others pick it up on their first table load after it

  • A startup warning when server.s3-compatible-storage.static-key-vending=static-key

  • A stored secret that cannot be read during a vend, or an STS response without complete credentials (a key, secret and session token that are not blank, and an expiration), returns "Failed to vend temporary storage credentials."; the server logs the reason

Compatibility: AWS vending is unchanged.

Tests: full server suite.

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

This pull request and its description were written by Isaac.

@yili-db

yili-db commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_vending branch from 0061aa1 to caf4dc0 Compare November 11, 2026 23:39
@yili-db

yili-db commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_vending branch from caf4dc0 to 17fad7e Compare November 12, 2026 03:19
@yili-db

yili-db commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_vending branch from 17fad7e to 627486e Compare November 12, 2026 07:00
@yili-db

yili-db commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_vending branch from 627486e to 6c9cd3e Compare November 12, 2026 23:23
@yili-db

yili-db commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_vending branch from 6c9cd3e to 3c798cd Compare November 13, 2026 01:12
@yili-db

yili-db commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

/review

yili-db added a commit that referenced this pull request Nov 13, 2026
…s fail (#2176)

## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2176/files) to
review incremental changes.
-
[stack/storage_errors](#2176)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2176/files)]

---------
**Description of changes**

The server's own AWS SDK calls (S3, STS) put the storage's error text,
which can name its endpoint, into error responses. They now return a
general error.

- `StorageExceptions`: an `SdkException` in the cause chain becomes
`INTERNAL` "Failed to access storage.", in `BaseExceptionHandler` and
`TransactionManager`
- the walk stops at a `BaseException`, which already says what callers
get
  - the cause is kept, so the handler logs it once with the response
- A failed `AssumeRole` returns `INTERNAL` "Failed to vend temporary
storage credentials.", with the STS exception as its cause
- A storage cleanup that fails this way records its error code and its
cause's class, such as `INTERNAL caused by StsException`, still without
any message text

Behavior change: the status and error code of these failures are
unchanged (`INTERNAL`, HTTP 500), but the message no longer includes the
storage or STS text. A storage failure anywhere in the cause chain now
takes precedence over the `INVALID_ARGUMENT`, `UNAUTHENTICATED` and
database error-code mappings, so an `IllegalArgumentException` that
wraps one is reported as `INTERNAL`. `BaseException`s the server builds
itself, such as the region errors in `FileOperationsImpl`, are
unaffected. Azure and GCS failures are not covered.

Note: independent of the S3-compatible storage stack (#2170 to #2175,
then #2169). Once this merges, #2172 adds a test that relies on this
error handling.

Tests: handler tests for the UC, Iceberg and Delta APIs;
`TransactionManagerTest`; `CloudCredentialVendorTest`.

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

This pull request and its description were written by Isaac.

---------

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
@yili-db
yili-db force-pushed the stack/s3compat_vending branch 2 times, most recently from a5be6ef to 967a04a Compare November 13, 2026 05:34
@yili-db

yili-db commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_vending branch from 967a04a to 2483fd9 Compare November 13, 2026 08:32
@yili-db

yili-db commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db marked this pull request as ready for review November 13, 2026 09:51
@yili-db
yili-db requested a review from shba24 November 13, 2026 09:52
@yili-db
yili-db force-pushed the stack/s3compat_vending branch from e46d27b to 7578d34 Compare November 16, 2026 10:10
@yili-db

yili-db commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@shba24 shba24 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @yili-db. No blockers at 7578d349. Validated:

  • The storage region header is checked before it is used for signing or sent to clients.
  • With the flag off, a vend fails with INVALID_ARGUMENT before the endpoint is contacted.
  • The cache key changes with the stored credential.
  • Incomplete AssumeRole answers fail closed.

@shba24 shba24 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving: no blockers from the review above.

@shba24 shba24 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @yili-db. No blockers at 7578d349. Validated: a credential update, a reported region and server vs client access each select their own cached vend, and the flag check runs before the stored endpoint is contacted. One nit inline.

awsIamRole.map(AwsIamRoleResponse::getExternalId).orElse(null),
s3CompatibleVersion,
context.getS3Endpoint(),
context.getS3Region(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit (not a blocker): the cache key's region and the s3_compatible fingerprint aren't pinned by any test. Dropping context.getS3Region() from the key, or making getCredentialFingerprint() return a constant, leaves every test green. The region matters here because S3BucketRegions returns the fallback us-east-1, then the reported region, at the same endpoint, and the cached response carries that region. Would two rows in changedBindings work, plus one real-DAO check?

        Arguments.of(
            "s3_compatible payload",
            s3CompatibleCtx("fp-1", false),
            s3CompatibleCtx("fp-2", false)),
        // The storage reports its region later than a fallback, at the same endpoint.
        Arguments.of(
            "reported region",
            s3CompatibleCtx("fp-1", false, "us-east-1"),
            s3CompatibleCtx("fp-1", false, "garage")));

with an s3CompatibleCtx(fingerprint, isServerAccess, region) overload, and in CredentialDAOTest:

  @Test
  public void testFingerprintChangesWithTheStoredPayload() {
    String one = "{\"access_key_id\":\"key-id-1\",\"s3_endpoint\":\"" + S3_ENDPOINT + "\"}";
    String two = "{\"access_key_id\":\"key-id-2\",\"s3_endpoint\":\"" + S3_ENDPOINT + "\"}";
    assertThat(CredentialDAO.builder().credential(one).build().getCredentialFingerprint())
        .isEqualTo(CredentialDAO.builder().credential(one).build().getCredentialFingerprint())
        .isNotEqualTo(CredentialDAO.builder().credential(two).build().getCredentialFingerprint());
  }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1, could we add the region and endpoint cases plus a real-dao fingerprint check?

@timothyw553 timothyw553 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

one concern about closing the shared credentials provider. i also have some comments on region handling, caching, tests and docs.

/** Closes the STS client, releasing its connections. */
@Override
public void close() {
stsClient.close();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to my understanding DefaultCredentialsProvider.create() returns a shared provider, and closing this client can close it too. could stopping one embedded server affect other aws clients in the same jvm? should we give this client its own provider and test that two vendors get different instances?

-        credentialsProvider = DefaultCredentialsProvider.create();
+        credentialsProvider = DefaultCredentialsProvider.builder().build();

details == null || details.sdkHttpResponse() == null
? Optional.empty()
: details.sdkHttpResponse().firstMatchingHeader(BUCKET_REGION_HEADER);
return Optional.of(region.orElseThrow(() -> e));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could an empty region header on a 503 or 403 discard a previously working region? this returns an empty string, so withoutRegion() clears the known region and uses us-east-1 for five minutes. should we treat it like a missing header and extend the recheck test to verify we keep the known region and retry after the shorter delay?

-      return Optional.of(region.orElseThrow(() -> e));
+      return Optional.of(region.filter(value -> !value.isBlank()).orElseThrow(() -> e));

// S3CompatibleStaticKeyVending. The server's own storage access always uses the key pair.
S3_COMPATIBLE_STATIC_KEY_VENDING(
"server.s3-compatible-storage.static-key-vending",
S3CompatibleStaticKeyVending.ENDPOINT_ONLY.value(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could we test this through real ServerProperties too? this setting controls whether stored keys leave the server, so it would be good to check the unset default, both accepted values, and rejection of invalid or wrongly cased values.

awsIamRole.map(AwsIamRoleResponse::getExternalId).orElse(null),
s3CompatibleVersion,
context.getS3Endpoint(),
context.getS3Region(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1, could we add the region and endpoint cases plus a real-dao fingerprint check?

@timothyw553 timothyw553 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this looks pre-existing: AwsPolicyGenerator uses URI::getHost, which returns null for a valid bucket such as data.2024. that produces resources like arn:aws:s3:::null/p/q/*, while the new region lookup uses the correct bucket. could we handle this in a follow-up and test the exact policy resources?

-                URI::getHost,
+                URI::getAuthority,

--
@yili-db this is ai assisted, let me know what you think

yili-db added a commit that referenced this pull request Nov 16, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2171/files) to
review incremental changes.
-
[stack/s3compat_spec](#2170)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2170/files)]
[MERGED]
-
[**stack/s3compat_credentials**](#2171)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2171/files)]
← _this PR_
-
[stack/s3compat_vending](#2172)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2172/files/1c90863a0a328f0bec36232d3518c4fd65b9b6b6..7578d349b6dfd243ba229f147bf2046ece7ffc54)]
-
[stack/s3compat_hadoop_cli](#2173)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2173/files/7578d349b6dfd243ba229f147bf2046ece7ffc54..df3d6a134500556e4368352bffde8d4099c20478)]
-
[stack/s3compat_test_storage](#2174)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2174/files/df3d6a134500556e4368352bffde8d4099c20478..c43d8b01648e305615c27110fd892fd631924830)]
-
[stack/s3compat_helm_key](#2175)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2175/files/c43d8b01648e305615c27110fd892fd631924830..1262f181a18b28b9c856e1367cc6301b57bd4fbf)]
-
[stack/s3compat_credentials_text](#2169)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2169/files/1262f181a18b28b9c856e1367cc6301b57bd4fbf..b7b769051dd8fccbc7578458ad68f1bd642adf93)]

---------
Part of a stack adding experimental S3-compatible storage (MinIO, Ceph,
SeaweedFS, RustFS, Garage): #2170 (merged) to #2175, then #2169. Each PR
builds on the one before it; the files changed since the previous PR are
under the link above.

**Description of changes**

Experimental `s3_compatible` storage credentials, off by default.

- `server.s3-compatible-storage.enabled` (default `false`): with it off,
`s3_compatible` credentials cannot be created, an update cannot set
`s3_compatible` fields, and none is used to vend credentials; other
updates, reads and deletes still work
- `CredentialDAO` stores the credential; `secret_access_key` is
write-only, and `sts_endpoint` is stored only when set
- The secret is encrypted in the database with AES-256-GCM
(`CredentialSecretStore`, `EncryptedCredentialSecretStore`)
- key in `server.credential-encryption-key`, set through
`UC_SERVER_CREDENTIAL_ENCRYPTION_KEY`; without it, such credentials
cannot be created
  - each value is bound to its credential id and field
- at startup the server warns about credentials whose stored value it
cannot read, with the reason
- `CredentialRepository` checks type changes against the credential's
external locations
- The key is read only with `server.s3-compatible-storage.enabled=true`;
a malformed key then stops the server at startup
- `s3_endpoint` and `sts_endpoint` must be exactly
`http[s]://host[:port]` (port 1 to 65535; no path, not even a lone `/`,
no empty port, user info, query or fragment; `localhost` and private
hosts are fine), since they are returned to everyone who can read the
credential; error messages leave a rejected value out; no spec change
(the `api/` files match `main`)
- `updateCredential` refuses a request with both `aws_iam_role` and
`s3_compatible` before its transaction
- The v1 encryption binding (`storage credential <id> <field>`) is fixed
apart from error messages; a fixture checks an earlier value still reads
- The locked lookup by name returns the row the database matched, as
MySQL's case-insensitive default collation does for other lookups
- A stored value that does not decrypt keeps the failure as the cause,
for the logs; one too short to hold a nonce and a tag is refused before
decrypting; a stored credential that is not a JSON object is refused as
`INTERNAL`, naming the credential, as is one that does not bind to its
schema
- `ExternalLocationRepository` requires `s3://` URLs with a bucket (no
user info or port) for `s3_compatible` credentials, on create and
update; `NormalizedURL.isS3Path` is the one rule, which
`validateLocationsAreS3Paths` applies to each of a credential's location
URLs; a stored URL that no longer parses, as an earlier release may have
stored, is not an `s3://` path, so such a location can still be renamed,
commented or moved to another credential, and the parser's error, which
names the URL, never reaches the caller
- A non-forced `deleteCredential` locks the credential too, so a
location added meanwhile blocks the delete
- The race tests wait until the competing change waits for the row lock
(`awaitLockWait`: `pg_stat_activity`, `performance_schema.data_locks` or
H2's `INFORMATION_SCHEMA.SESSIONS`, showing what the database reports
when no session waits), so each fails without the lock it checks
- `assume_role.sts_region` must be letters, digits, '.', '_' and '-'; a
create with neither credential type returns `INVALID_ARGUMENT`
- credential updates and location changes lock the credential row on its
first read in the transaction (`getCredentialDAOForUpdate`; a location
update locks the location first), so a type change and a location change
on one credential cannot race, and the lock never lands on a copy read
earlier without it
- rows are locked by id and name with main's `RepositoryUtils.lockByKey`
helpers (`getForUpdateByName` reads the id first), so a rename that
commits meanwhile finds nothing: names have no index on MySQL, where a
locking read by name locked a range and could deadlock with a concurrent
create; these transactions run at READ COMMITTED, so reads after the
lock see what was committed while it waited; a lock failure returns
`UNAVAILABLE`, to retry
- a location update checks its URL against the credential's committed
type whether or not the URL changes
- Schema step `V3__s3_compatible_credential_type`, with its effect files
- PostgreSQL replaces the `credential_type` CHECK in one statement:
`DROP CONSTRAINT k, ADD CONSTRAINT k CHECK (credential_type IN (...))`,
where `k` is the column's CHECK, `uc_credentials_credential_type_check`
- `MigrationStepRulesTest` (from #2113) allows that change: on
PostgreSQL a step may replace a column's CHECK of its values with one
that keeps every value, so rows already there pass it. Until now its
rules said adding a Java enum constant on PostgreSQL was not supported
yet. `AGENTS.md` says so too.
- CLI (the key options keep their names): `--s3_access_key_id`,
`--s3_secret_access_key`, `--s3_endpoint`, `--s3_sts_endpoint`,
`--s3_role_arn` and `--s3_sts_region` on credential create and update

Known: on MySQL, a stored credential must fit `tinytext` (255 bytes)
until #2169 widens the column; an `s3_compatible` credential with
`assume_role` and real endpoints usually does not (`TODO(#2169)` on
`CredentialDAO.setS3Compatible`).

The spec text from #2170 also describes vending, which #2172 adds; the
stack is meant to land together.

Compatibility: additive and behind the flag; `aws_iam_role` credentials
are unchanged.

Tests: credential, external location, repository, DAO and secret store
tests (SDK and CLI), and the schema tests, with
`UC_TEST_MIGRATION_CHECKS=true`, on H2, PostgreSQL 18 and MySQL 8.

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

This pull request and its description were written by Isaac.

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
@yili-db
yili-db force-pushed the stack/s3compat_vending branch from 7578d34 to 58f35c7 Compare November 16, 2026 23:02
@yili-db

yili-db commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db

yili-db commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @timothyw553, good catch on URI::getHost in AwsPolicyGenerator. It predates this PR and affects AWS vending too, so I will fix it in a separate follow-up after the S3-compatible PRs land, with a test of the exact policy resources.

@yili-db
yili-db requested a review from timothyw553 November 16, 2026 23:02

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

some comments on test coverage and documentation. the iceberg cache issue and design questions can be follow-ups.

// Iceberg's refreshing credentials provider requires a session token, so a vended key pair goes
// without its lifetime and the refresh endpoint, and an Iceberg client keeps it until the table
// is loaded again.
if (awsCredentials.getSessionToken() != null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could an iceberg reload keep returning 304 after we rotate the keys or change the endpoint? the etag only covers metadata and permissions, and these modes have no credential refresh endpoint. should we include the credential version and storage settings in the etag, or bypass 304 for these responses, with a regression test? fine to track this as a follow-up.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Agreed to take this as a follow-up: I will open a separate PR to cover the credential version and storage settings in the ETag (or skip 304 for these responses), with a regression test.

vendor.vendCredential(
NormalizedURL.from(COMPAT_PATH),
CredentialContext.READ_ONLY,
c.isServerAccess() ? CredentialUse.SERVER : CredentialUse.CLIENT);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what about CredentialUse.cleanup(...)? cleanup needs usable keys even when clients only receive the endpoint, but this matrix never checks that mapping through the real storage vendor. could we store CredentialUse instead of the boolean and add cleanup cases for both modes?

*/
public static Optional<String> headBucketRegion(S3Client s3Client, String bucket) {
try {
return Optional.ofNullable(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could a successful response return a blank region here? the compatible-storage caller checks again, but the aws caller accepts any present value. should we filter it here and add a successful response with a blank region to the tests?

 return Optional.ofNullable(
-    s3Client.headBucket(HeadBucketRequest.builder().bucket(bucket).build()).bucketRegion());
+        s3Client.headBucket(HeadBucketRequest.builder().bucket(bucket).build()).bucketRegion())
+    .filter(region -> !region.isBlank());

s3Compatible.getAccessKeyId(), secretAccessKey(credentialDAO)));
return Optional.of(assumeS3CompatibleRole(key, context, assumeRole.getRoleArn(), signer));
}
if (context.isServerAccess()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i wonder if we could cache an internal credential result and apply the client key-removal policy at the storage-vendor boundary? currently caller policy reaches into both vending and the cache key. fine as a follow-up, but sharing server/client entries would also need the same one-hour refetch expiry first, since server keys currently have none.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, a follow-up. I will look at caching one internal result and removing client keys at the storage-vendor boundary in a separate PR, starting with the same one-hour refetch expiry for server keys.

// use while that request fails.
static final Duration REPORTED_REGION_TTL = Duration.ofHours(1);
private static final int MAX_BUCKETS = 10_000;
private final Cache<StorageBucket, Reported> reportedRegions;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we now have separate region caches and lookup policies here and in FileOperationsImpl. could we share more of the normalization and lookup mechanics while keeping the different fallback rules explicit? discovery also adds a synchronous storage request to vending, so configured-region support may be worth considering separately. fine as a follow-up.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, a follow-up. I will share the normalization and lookup between S3BucketRegions and FileOperationsImpl in a separate PR, keeping the two fallbacks explicit, and consider a configured-region option there.

- With `assume_role`: `AssumeRole` at `sts_endpoint` (or `s3_endpoint` when unset), signed per request with the credential's key pair, through keyless STS clients cached per endpoint and region (at most 100; an evicted one closes after the calls using it)

- Without it, `server.s3-compatible-storage.static-key-vending` decides what clients get: `endpoint-only` (default) or `static-key`

- `S3BucketRegions` reads the bucket's region with one lookup per bucket at a time; the default region is asked again later

- `CachingCloudCredentialVendor` keys on the credential's fingerprint, endpoint and region, and server vs client access

- A secret that cannot be read during a vend returns a general error

- `FileOperationsImpl` and `DeltaCredentialsMapper` use the endpoint and region

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
@yili-db

yili-db commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_vending branch from 58f35c7 to e495e89 Compare November 17, 2026 02:56
@yili-db
yili-db requested a review from timothyw553 November 17, 2026 02:56
@yili-db
yili-db merged commit cdc1006 into unitycatalog:main Nov 17, 2026
24 checks passed
yili-db added a commit that referenced this pull request Nov 17, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2173/files) to
review incremental changes.
-
[stack/s3compat_spec](#2170)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2170/files)]
[MERGED]
-
[stack/s3compat_credentials](#2171)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2171/files)]
[MERGED]
-
[stack/s3compat_vending](#2172)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2172/files)]
[MERGED]
-
[**stack/s3compat_hadoop_cli**](#2173)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2173/files)]
← _this PR_
-
[stack/s3compat_test_storage](#2174)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2174/files/7d5ddf7e9720b6f2cec3fc71ccb53d54d8673ae7..e7e2bc04280b0b124a3a9a3a2900c0e90f0b46ff)]
-
[stack/s3compat_helm_key](#2175)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2175/files/e7e2bc04280b0b124a3a9a3a2900c0e90f0b46ff..4443034338bd1eca465258461ca6426763358b6a)]
-
[stack/s3compat_credentials_text](#2169)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2169/files/4443034338bd1eca465258461ca6426763358b6a..ed888a1e8e6bd11d226dbc2c354006a9e26e3b8f)]

---------
Part of a stack adding experimental S3-compatible storage (MinIO, Ceph,
SeaweedFS, RustFS, Garage): #2170 (merged) to #2175, then #2169. Each PR
builds on the one before it; the files changed since the previous PR are
under the link above.

**Description of changes**

Engines use the endpoint and region vended for S3-compatible storage.

- `S3CredPropsBuilder` sets `fs.s3a.bucket.<bucket>.endpoint`,
`.endpoint.region` and `.path.style.access` per vended credential, and
the vended keys with a provider that reads them
(`SimpleAWSCredentialsProvider` or `TemporaryAWSCredentialsProvider`),
or the vended provider with renewal, since a bucket option in the
engine's configuration overrides a global one
- the bucket is read from the prefix as text, so underscores and
characters invalid in a URI work
- two credentials that put one bucket on different storage are rejected
- `FileSystemCredId`: for a bucket with an S3 endpoint, the
credential-scoped file system cache key includes a hash of the bucket
and every S3A option for it, at bucket scope and global (the endpoint
and region, transport and signing options, and the engine's own S3A
credentials, credential stores and assumed role), except the per-load
`fs.s3a.init.*` credentials and other buckets' options, so one bucket
name on two storages, or under two engine S3A configurations, never
shares a file system ; for any S3 path without vended keys (the table
load records whether the vended keys sign the bucket's requests, as
`fs.unitycatalog.vended.s3.keys.<bucket>`: not for a keyless vend,
several AWS S3 credentials without renewal, or an engine whose own
bucket provider, bucket keys without renewal, or global provider without
renewal signs instead, or, without renewal, any configured Hadoop
credential store, which S3A reads before the vended keys, or S3A
delegation tokens, whose token signs; a value only from Hadoop's own
defaults, such as S3A's default provider list, does not count as the
engine's), or a bucket the table load did not route, the key includes
the S3A settings hash and the current Hadoop user, told apart as
Hadoop's own file system cache does (so two users of one name with
different credentials do not share), since the engine then signs with
its own keys, which may differ per user however the engine resolves
them; AWS S3 paths with vended keys keep their key, unless the engine
sets a global `fs.s3a.endpoint` or `fs.s3a.endpoint.region`, or the
bucket's own `endpoint.region`
- Credentials without keys leave the engine's own S3A credentials in
use, without the vended provider
- S3-compatible keys and the vended provider are set only at the scope
of their buckets; a table whose credentials are all S3-compatible gets
no global provider or keys, so another bucket the file system opens does
not get them. The storage hash matches the URI scheme
case-insensitively.
- several credentials with keys for S3-compatible storage need
credential renewal and credential-scoped file systems, or the table load
refuses them
- a table's credentials are assumed to be all with keys or all without;
a mix is rejected, with a `TODO` to process each credential on its own
- Renewal only for credentials that can expire; several credentials
always take the vended provider, which picks the one covering each path
- the table load records each bucket's vended endpoint and region
(`fs.unitycatalog.vended.s3.*`, empty for AWS S3), and a renewal for
other storage, including a switch between AWS S3 and S3-compatible
storage, fails with a message that names both storages and asks to load
the table again, since the open file system keeps its endpoint; a
renewal that changes only the region, as after the server first used a
fallback, is taken; the initial credential's region travels as
`fs.s3a.init.s3.region`
- the check compares a renewal with the record of the bucket the file
system serves (from its prefix, or the table's only recorded bucket),
and refuses a renewal for another bucket, as for a table recreated
elsewhere; it runs once per credential rather than per request; a bucket
without a record, or a renewal with no storage path to check, takes only
AWS S3 renewals; the provider credential cache keys on the recorded
storage, so a table loaded for new storage does not get a credential
cached for the old one; `fs.s3a.init.s3.endpoint` and `.region` are
always written, empty when unset
- `AwsVendedTokenProvider` returns `AwsBasicCredentials` for a key pair
without a session token
- a renewal that gets only the endpoint, for example after the server's
vending mode changed, fails with a message to load the table again
- A vended key pair without a session token sets `fs.s3a.session.token`
to empty, so a configured token is not paired with it
- When every credential is for S3-compatible storage, no global vended
provider is set, and one the engine's own configuration lists is dropped
from its list, keeping its other providers (an empty list is S3A's
default chain), so the keys reach only their buckets
- `DeltaKernelUtils` (CLI) sets the vended endpoint, region and, for
S3-compatible storage, the keys at the table's bucket scope only (global
keys for AWS S3); only a response with just the endpoint leaves the keys
to the environment, and a session token that is set must not be empty;
the CLI turns off Hadoop's S3A file system cache, whose key ignores the
endpoint and keys
- `AwsCredential` treats an empty endpoint, region or session token as
absent, as the renewal path already did
- The same-bucket check counts AWS S3 paths too, so a bucket name on
both AWS and S3-compatible storage is rejected rather than sent to one
of them
- A session token stays required without an S3 endpoint: the provider
reads the endpoint back from `fs.s3a.init.s3.endpoint`, and otherwise
fetches from Unity Catalog as before; an empty
`fs.s3a.init.session.token` is no token
- Responses without storage credentials, or without a cloud config,
still fail as before

Known:
- An open file system does not follow a change of a credential's
storage: its renewal fails instead, and the next table load gets the new
storage.
- Without a bucket-scoped endpoint the cache key has no storage hash, so
engine configurations that differ only in their own global
`fs.s3a.endpoint` or path style share a credential-scoped file system,
as before this change.
- A credential store entry (`hadoop.security.credential.provider.path`)
for a bucket's `access.key` or `secret.key` takes precedence over fixed
vended keys, as for the global keys on the AWS path.

The `--s3_*` CLI options are documented with the user docs, later in the
series.

Compatibility: AWS, Azure and GCS behavior is unchanged.

Tests: Hadoop connector and CLI suites.

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

This pull request and its description were written by Isaac.

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit that referenced this pull request Nov 17, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2174/files) to
review incremental changes.
-
[stack/s3compat_spec](#2170)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2170/files)]
[MERGED]
-
[stack/s3compat_credentials](#2171)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2171/files)]
[MERGED]
-
[stack/s3compat_vending](#2172)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2172/files)]
[MERGED]
-
[stack/s3compat_hadoop_cli](#2173)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2173/files)]
[MERGED]
-
[**stack/s3compat_test_storage**](#2174)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2174/files)]
← _this PR_
-
[stack/s3compat_helm_key](#2175)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2175/files/e4edf9f3cb2f7685ca8d668575fba4965e074cc0..e6386ee8b80766ae9be833dc4eacea0b024af8fd)]
-
[stack/s3compat_credentials_text](#2169)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2169/files/e6386ee8b80766ae9be833dc4eacea0b024af8fd..5f03fa8c88f5ccda9608158e0585bdcac6a8c08e)]

---------
Part of a stack adding experimental S3-compatible storage (MinIO, Ceph,
SeaweedFS, RustFS, Garage): #2170 (merged) to #2175, then #2169. Each PR
builds on the one before it; the files changed since the previous PR are
under the link above.

**Description of changes**

Runs the tests on real S3-compatible storage in Docker. Tests, sbt
aliases and an `AGENTS.md` line only; the spec and connector changes in
the diff against `main` come from #2170 to #2173.

- `server/src/test/.../teststorage`: a harness selected by
`UC_TEST_STORAGE`, like `UC_TEST_DATABASE`
  - MinIO, SeaweedFS and RustFS with STS
  - Ceph and Garage without STS, in both `static-key-vending` modes
- sbt aliases: `testMinIO`, `testSeaweedFS`, `testRustFS`, `testCeph`,
`testCephStaticKey`, `testGarage`, `testGarageStaticKey`
- `S3CompatibleCredentialScopeTest`: on real storage, a session vended
for a table, a path or a volume reaches only its directory (a sibling, a
prefix twin and the bucket root are denied, for reads, writes, deletes
and lists), a write credential deletes only there, and a read credential
cannot write or delete
- `S3CompatibleCredentialVendingTest`: every vending endpoint, per
credential and mode
- The storage suites and `BaseSparkIntegrationTest` turn on
`server.s3-compatible-storage.enabled` (off by default in
`BaseServerTest`)
- `BaseSparkIntegrationTest` runs the Spark suites on the selected
storage, resolved on use (`s3Storage()`) so a failed start reports its
cause in each suite; with an endpoint-only vend the engine brings only
the keys, and the routing comes from the vend, except for the bucket
that gets none
- `AGENTS.md` mentions the aliases

- Each storage stops what it started when its start or setup fails, and
`TestStorages.selected` remembers the failure, so later tests fail at
once
- `McRunner`, shared by MinIO and RustFS, retries a dropped or hung `mc`
admin call (each attempt runs under `timeout` with at most 20 seconds of
the time left) for up to a minute; a retried change already in effect
counts as done; each harness S3 request is capped at 20 seconds, so the
setup loops reach their deadline; Ceph and Garage setup commands run
with a deadline too (`ContainerExec`), and a failed Ceph install points
at `CEPH_VERSION`, since Ubuntu's index keeps only the newest build

Not in CI: the aliases are run manually, and need Docker.

Tests: Spark emulated; MinIO: scope, vending and Spark suites; Garage:
vending and Spark suites (the scope suite is skipped, since Garage has
no STS to scope sessions).

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

This pull request and its description were written by Isaac.

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit that referenced this pull request Nov 18, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2175/files) to
review incremental changes.
-
[stack/s3compat_spec](#2170)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2170/files)]
[MERGED]
-
[stack/s3compat_credentials](#2171)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2171/files)]
[MERGED]
-
[stack/s3compat_vending](#2172)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2172/files)]
[MERGED]
-
[stack/s3compat_hadoop_cli](#2173)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2173/files)]
[MERGED]
-
[stack/s3compat_test_storage](#2174)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2174/files)]
[MERGED]
-
[**stack/s3compat_helm_key**](#2175)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2175/files)]
← _this PR_
-
[stack/s3compat_credentials_text](#2169)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2169/files/072e1addbbc64a6b3169931e97debeef205b2475..818485843e842b8d934adc3b6a115ae1747316de)]

---------
Part of a stack adding experimental S3-compatible storage (MinIO, Ceph,
SeaweedFS, RustFS, Garage): #2170 (merged) to #2175, then #2169. Each PR
builds on the one before it; the files changed since the previous PR are
under the link above.

**Description of changes**

The Helm chart passes the credential encryption key from a Kubernetes
Secret.

- `server.credentialEncryptionKeySecret`: the Secret named by `name`
gives `UC_SERVER_CREDENTIAL_ENCRYPTION_KEY` from its `key` (default
`encryptionKey`), through the existing secret env helper
- only needed for the experimental `s3_compatible` credentials; unset by
default
- CI:
- render checks: the variable renders once, from the Secret's name and
key (default and custom), with every database, in the server container's
one env list; a default render has none; no render writes the key to the
generated properties
- install: the PostgreSQL case creates a key Secret with `openssl rand
-base64 32`, turns on `server.s3-compatible-storage.enabled`, and checks
the server becomes ready and read the key; the file and MySQL cases keep
the default install
- Docs:
- `docs/server/configuration.md`: the key's environment variable, that
the chart passes it with any database, and when it is needed
- chart README: a complete example (the Secret plus the flag), linked
from the `server.config.override` and
`server.credentialEncryptionKeySecret.name` docs
- Regenerated `helm/README.md`

Compatibility: additive and opt-in.

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated

This pull request and its description were written by Isaac.

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit that referenced this pull request Nov 20, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2169/files) to
review incremental changes.
-
[stack/s3compat_spec](#2170)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2170/files)]
[MERGED]
-
[stack/s3compat_credentials](#2171)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2171/files)]
[MERGED]
-
[stack/s3compat_vending](#2172)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2172/files)]
[MERGED]
-
[stack/s3compat_hadoop_cli](#2173)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2173/files)]
[MERGED]
-
[stack/s3compat_test_storage](#2174)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2174/files)]
[MERGED]
-
[stack/s3compat_helm_key](#2175)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2175/files)]
[MERGED]
-
[**stack/s3compat_credentials_text**](#2169)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2169/files)]
← _this PR_
-
[stack/s3compat_location_endpoint](#2289)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2289/files/76859fc160061ad821312ef6bc69f986e9c44e5f..708dcb589fb36067a3e15464c2fd5513cddab4cb)]

---------
Last of a stack adding experimental S3-compatible storage (MinIO, Ceph,
SeaweedFS, RustFS, Garage): #2170 to #2175 are merged.

**Description of changes**

Stores credentials as text instead of PostgreSQL large objects, and
widens the column on MySQL, where `tinytext` (255 bytes) is too small
for real `s3_compatible` credentials with `assume_role`. It makes the
change #1928 plans for `uc_credentials.credential`, and is a placeholder
until #1928 and its follow-up merge.

Builds on #2117 (merged): the server starts only once the steps have
run, so it never sees the column before step V4.

- `CredentialDAO.credential` drops `@Lob` and adds `length = 16777215`
- Schema step `V4__credentials_credential_as_text`, one statement per
database:
  - MySQL: `tinytext` to `mediumtext`
- PostgreSQL: large object (`oid`) to `text`, through
`convert_from(lo_get(credential), 'UTF8')`
  - H2: no change
- Schema effect files for V4
- `docs/server/upgrades.md`:
- the PostgreSQL step reads every credential's large object as UTF-8, as
`hibernate.connection.username`; a missing or unreadable one fails it,
with how to recover
- the large objects stay (still holding the earlier stored values) for
`vacuumlo`, and a release from before the step cannot read the converted
column on PostgreSQL
- Removes the `TODO(#2169)` on `CredentialDAO.setS3Compatible`
- `SchemaMigratorTest.upgradeKeepsStoredCredentialsAndFitsLongerOnes`: a
credential stored before the step (a large object on PostgreSQL, with
two-, three- and four-byte characters) reads back as the same text, and
one longer than 255 bytes fits, on all three databases; on PostgreSQL
the old row is written through pgjdbc's large object path
- `SchemaMigratorTest.upgradeWithAMissingLargeObjectChangesNothing`: on
PostgreSQL, a credential whose large object is missing fails the step
and leaves the column and the row as they were
- `MigrationStepRulesTest`: MySQL `tinytext` widens to `text`,
`mediumtext` or `longtext`; on PostgreSQL an `oid` column may change
only as `TYPE text USING convert_from(lo_get(c), 'UTF8')`, the one
allowed change that rows can fail, with cases for it; a plain type
change of an `oid` column is refused
-
`SchemaMigratorTest.refusesAStepThatDropsAConstraintTheDatabaseNoLongerHasByThatName`
brings the database to step 3 itself instead of to the newest step, so a
later step no longer leaves a gap in its schema history
- `BaseCredentialCRUDTest.testLongS3CompatibleCredential`: a credential
over 1000 bytes, with non-ASCII text, round-trips through the server on
every database

Compatibility: no API change. Going back to an earlier release needs the
database backup.

Tests: `SchemaMigratorTest`, `BaselineMatchesEntitiesTest`,
`MigrationStepRulesTest` and the credential and external location CRUD
tests on H2, PostgreSQL 18 and MySQL 8 (`MigrationStepRulesTest` with
`UC_TEST_MIGRATION_CHECKS=true`); all pass.

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated

This pull request and its description were written by Isaac.

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit that referenced this pull request Dec 2, 2026
…he, not in it (#2268)

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [x] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

What a client may receive of an `s3_compatible` key pair was decided in
two places: in vending (`AwsCredentialVendor`) and in the vend cache key
(`CachingCloudCredentialVendor`). This moves it to one place, the
storage vendor, after the cache. What every caller receives is
unchanged, apart from the lifetime noted below.

Before, without `assume_role`:
- the server, and its storage cleanup, got the key pair with no
expiration
- a `static-key` client got the key pair with a one-hour refetch time
- an `endpoint-only` client got only the endpoint and region
- so the cache key carried `isServerAccess`, and server and client vends
of one credential never shared an entry

Changes:
- `AwsCredentialVendor` always vends the key pair with the one-hour
refetch time, for every caller; it no longer reads
`server.s3-compatible-storage.static-key-vending`
- The `CachingCloudCredentialVendor` key drops `isServerAccess`, so the
server, the cleanup and `static-key` clients share one entry
- `StorageCredentialVendorImpl` applies the client policy: an
`endpoint-only` client, on an `s3_compatible` credential without
`assume_role`, gets only the endpoint and region, with the same
lifetime, built there without vending, so its secret is still never
loaded
- `CredentialContext.isServerAccess` and the empty-vend branch of
`CloudCredentialVendor` have no users left and are removed

Credential updates reach callers as before: the cache key holds a
fingerprint of the stored credential, so the next vend after an update
misses the cache.

Follow-up from the review of #2172.

Tests:
- `CloudCredentialVendorTest` defaults to the `endpoint-only` mode, and
the `assume_role` test runs in it, so the guard that lets `assume_role`
credentials vend sessions to clients is covered
- `isEndpointOnlyForClient` uses an exhaustive `switch` on `Purpose`, so
a new purpose has to choose
- Docs: the audit `expires_at` of a key pair tells renewing clients when
to fetch it again; it also caps cache reuse, which the max age and the
expiry margin usually end sooner; `endpoint-only` responses carry it
without the cache
-
`CloudCredentialVendorTest.testS3CompatibleWithoutAssumeRoleVendsPerServerMode`
also checks, behind the vend cache in `endpoint-only` mode, that a
client never gets the key pair the server's vend cached, and that its
requests skip the cache
-
`CloudCredentialVendorTest.testS3CompatibleWithoutAssumeRoleVendsPerServerMode`
expects the lifetime for every use, and checks that a server and a
`static-key` client share one cached vend (the secret is loaded once)
- `CachingCloudCredentialVendorTest` drops the two cases about server
and client entries; distinct credential versions stay covered by
`changedBindings`
- `build/sbt "server/testOnly
io.unitycatalog.server.service.credential.*"`, and the server suite on
H2 (`dev/run-tests.py server/test`)

Compatibility: no API or configuration change. The server's own vends of
an `s3_compatible` key pair now carry the one-hour lifetime too. For
them it only caps reuse from the vend cache, which
`server.storage-credential-cache.max-age` (5 minutes by default) and the
one-minute expiry margin usually end sooner, and their audit records now
show that time as `expires_at`; clients see no change.

This pull request and its description were written by Isaac.

---------

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit that referenced this pull request Dec 2, 2026
…atible storage (#2267)

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [x] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

The server looked up S3 bucket regions in two places with two sets of
rules: `FileOperationsImpl` for AWS buckets (the Iceberg
`client.region`) and `S3BucketRegions` for S3-compatible storage (the
vended signing region). Both send an anonymous HeadBucket, but only
`S3BucketRegions` bounds its cache, rechecks regions, backs off after
failures and runs one lookup per bucket. This shares that lookup,
keeping the two fallback rules explicit.

- `S3BucketRegions.getAwsRegion(bucket)` serves AWS buckets with the
same lookup as `getS3CompatibleRegion`:
- a reported region is cached per bucket, at most 10,000 buckets, and
asked again after an hour (the AWS map was unbounded and never
rechecked)
- a failed recheck keeps the reported region, and the bucket is asked
again only after the 30-second backoff
  - one lookup runs per bucket at a time
- an AWS bucket in backoff whose reported region was evicted is asked
again, never given the S3-compatible default (the two caches evict
apart)
- a failure to build the lookup client is handled as a failed request:
as before on S3-compatible storage; for an AWS bucket it is now a
retriable `INTERNAL` error instead of an unhandled exception
  - each request is capped at 10 seconds
- AWS lookups address the bucket virtual-hosted, the SDK default as
before; S3-compatible lookups keep the location's addressing style
(`path_style_access`)
- a 404 drops the reported region on S3-compatible storage, where the
bucket may be created again with another region; an AWS bucket keeps it,
as for any failed recheck (noted in the class javadoc)
- Fallbacks stay explicit and unchanged:
- S3-compatible storage without a known region uses `us-east-1` and asks
again later
- an AWS bucket without a known region fails with `FAILED_PRECONDITION`
(no region, such as no such bucket) or `INTERNAL` (transient), with the
same messages as before, and is asked again on the next request
- `FileOperationsImpl` keeps only the regions configured with
`s3.bucketPath.N`/`s3.region.N` and asks `S3BucketRegions` for the rest
- Tests:
-
`S3BucketRegionsTest.testAwsBucketKeepsItsReportedRegionOnAFailedRecheck`,
parameterized over a recheck that fails with 503, 404, 403 without a
region, 200 without a region, or a malformed region: the region is kept,
the 30-second backoff holds, and an eviction during it fails the lookup
(through a test-only `evictReportedRegion`)
- `testAwsBucketWithoutAKnownRegionHasNoDefault`: no default for an AWS
bucket
- `testConcurrentRequestsShareOneLookup`, for a success and for a
failing AWS lookup that a second caller waits on
- `testReportedRegionIsUsedAndCachedPerStorageAndBucket`: two AWS
buckets on one instance each get their own region, apart from the same
name on S3-compatible storage, and the lookup client has the 10-second
timeout
- `FileOperationsTest` discovers the region of `my_bucket`, which is not
a host name; the other region cases pass unchanged (their mock builder
now also stubs `overrideConfiguration`, for the timeout)

Follow-up from the review of #2172. #2264 fixes how both places read a
bucket name that is not a valid host name (`URI::getAuthority`); this PR
already reads it that way, so whichever merges second needs a small
rebase.

A configured region for S3-compatible storage, to avoid the lookup
entirely, is left for a separate proposal.

Tests: `build/sbt "server/testOnly *S3BucketRegionsTest
*FileOperationsTest"`, and the server suite on H2 (`dev/run-tests.py
server/test`).

Compatibility: no API or configuration change. An AWS bucket's region is
now asked again after an hour instead of cached for the server's
lifetime, and a recheck that fails keeps the earlier region. A malformed
`x-amz-bucket-region` header from AWS is now refused like a missing one
(`FAILED_PRECONDITION`, unless a region was reported before), as it
already was for S3-compatible storage.

This pull request and its description were written by Isaac.

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
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.

3 participants