Repository navigation
[Server] Decide what clients receive of a key pair after the vend cache, not in it - #2268
Conversation
|
/review |
timothyw553
left a comment
There was a problem hiding this comment.
looks clean overall. left one comment on test coverage for ENDPOINT_ONLY with assume_role, plus a few small nits on comments and hardening.
| && staticKeyVending == S3CompatibleStaticKeyVending.ENDPOINT_ONLY | ||
| && credentialDAO | ||
| .filter(dao -> dao.getCredentialType() == CredentialType.S3_COMPATIBLE) | ||
| .filter(dao -> dao.getS3CompatibleResponse().getAssumeRole() == null) |
There was a problem hiding this comment.
do we have a test covering this assume_role guard under ENDPOINT_ONLY (the default)? right now testS3CompatibleAssumesRoleOnItsOwnStsEndpoint sets STATIC_KEY and setUp() leaves the mode null, so removing this filter wouldn't fail any test. could we run that test with ENDPOINT_ONLY (or both modes) and maybe default setUp() to ENDPOINT_ONLY?
when(serverProperties.getS3CompatibleStaticKeyVending())
- .thenReturn(S3CompatibleStaticKeyVending.STATIC_KEY);
+ .thenReturn(S3CompatibleStaticKeyVending.ENDPOINT_ONLY);| } | ||
| // Clients get only the S3 endpoint, so the secret is not loaded from its store. | ||
| return Optional.empty(); | ||
| // The key pair itself does not expire. A lifetime makes callers vend again, so an update of the |
There was a problem hiding this comment.
to my understanding FileOperationsImpl only applies expiry/refresh when a session token is present, so a static key pair doesn't actually make callers vend again every hour (and this also makes server/cleanup audit records log expires_at for keys that don't expire). should we reword this comment, the PR description, and the audit docs to say the timestamp only limits cache reuse?
There was a problem hiding this comment.
Partly. For clients the lifetime does make callers vend again: the UC Hadoop connector renews a key pair that has a lifetime (AwsCredential.isRenewable), so the UC credential and Delta paths pick up an updated key pair. Only the Iceberg REST config drops it, as you say: FileOperationsImpl passes an expiry only with a session token.
For the server's own vends and the cleanup, you're right that it only bounds how long the vend cache reuses the key pair, and their audit records now show that time as expires_at. I reworded the comment here, the audit docs (docs/server/configuration.md) and the PR description to say that.
| Optional<String> s3Endpoint, | ||
| Optional<String> s3Region, | ||
| boolean isServerAccess) { | ||
| Optional<String> s3Region) { |
There was a problem hiding this comment.
nit: since isServerAccess is gone from Key, the class javadoc (around line 38) still says the cache key includes whether the server or a client uses the credential. could we update that too?
| */ | ||
| private boolean isEndpointOnlyForClient( | ||
| Optional<CredentialDAO> credentialDAO, CredentialUse use) { | ||
| return use.getPurpose() == Purpose.CLIENT |
There was a problem hiding this comment.
if someone adds a new Purpose later, use.getPurpose() == Purpose.CLIENT will silently bypass the endpoint-only check without a compile error. could we keep an exhaustive switch here so new purposes have to choose explicitly?
- return use.getPurpose() == Purpose.CLIENT
+ boolean isClient =
+ switch (use.getPurpose()) {
+ case CLIENT -> true;
+ case SERVER, CLEANUP -> false;
+ };
+ return isClient
&& staticKeyVending == S3CompatibleStaticKeyVending.ENDPOINT_ONLYe54ce23 to
e14d7df
Compare
|
/review |
timothyw553
left a comment
There was a problem hiding this comment.
no production issues here. left one comment on ENDPOINT_ONLY cache test coverage and a few small nits on comments and docs.
| - `access` is `READ` or `READ_WRITE`: the access the request asked for. A static credential, such as | ||
| configured S3 keys, is returned as configured and can allow more. `expires_at` is when the | ||
| credential expires. Records never contain credential values. | ||
| credential expires. A key pair of `s3_compatible` storage does not expire: its `expires_at` is |
There was a problem hiding this comment.
to my understanding expires_at isn't actually when cache reuse stops, since cache max-age (5m default vs 1h lifetime) and expiry margin can stop reuse earlier, and endpoint-only responses set it without hitting the cache. could we adjust this and update the PR description to match?
- credential expires. A key pair of `s3_compatible` storage does not expire: its `expires_at` is
- when the server stops reusing it from the credential cache, and when clients that renew fetch it
- again. Records never contain credential values.
+ credential expires. An `s3_compatible` key pair does not expire. Its `expires_at` is a client
+ refresh hint that also limits cache reuse. Cache max-age and the expiry margin can stop reuse
+ earlier. Endpoint-only responses carry a refresh hint and bypass the credential cache.
+ Records never contain credential values.…he, not in it - `AwsCredentialVendor` vended an `s3_compatible` key pair differently per caller (no expiry for the server, a refetch time for `static-key` clients, nothing for `endpoint-only` clients), so `CachingCloudCredentialVendor` kept server and client entries apart - Without `assume_role` it now always vends the key pair with the one-hour refetch time, and the cache key drops `isServerAccess`, so the server, the storage cleanup and `static-key` clients share one entry - `StorageCredentialVendorImpl` applies the client policy: an `endpoint-only` client gets only the endpoint and region, built there without vending, so the secret is not loaded - `CredentialContext.isServerAccess` and the empty-vend branch of `CloudCredentialVendor` have no users left and are removed - Tests: the vending-mode matrix expects the lifetime for every use, and checks that a server and a `static-key` client share one cached vend Signed-off-by: Yi Li <[email protected]> Co-authored-by: Isaac <[email protected]>
…purpose switch - `CloudCredentialVendorTest`: `setUp` defaults to the `endpoint-only` mode, and `testS3CompatibleAssumesRoleOnItsOwnStsEndpoint` runs in it, so the `assume_role` guard in `isEndpointOnlyForClient` is tested - `isEndpointOnlyForClient` decides by an exhaustive `switch` on `Purpose` - Key pair lifetime: the `AwsCredentialVendor` comment and the audit docs say it bounds cache reuse and tells renewing clients when to fetch again, and that Iceberg REST carries none - `CachingCloudCredentialVendor` javadoc: server and clients share an entry Signed-off-by: Yi Li <[email protected]> Co-authored-by: Isaac <[email protected]>
…fetime wording - `CloudCredentialVendorTest.testS3CompatibleWithoutAssumeRoleVendsPerServerMode`: in `endpoint-only` mode, behind the vend cache, a client never gets the key pair the server's vend cached, and its requests skip the cache - `docs/server/configuration.md`: an `s3_compatible` key pair's `expires_at` 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 - `AwsCredentialVendor`: the same wording, and the comment rewrapped Signed-off-by: Yi Li <[email protected]> Co-authored-by: Isaac <[email protected]>
e14d7df to
b3c74a2
Compare
|
/review |
| && staticKeyVending == S3CompatibleStaticKeyVending.ENDPOINT_ONLY | ||
| && credentialDAO | ||
| .filter(dao -> dao.getCredentialType() == CredentialType.S3_COMPATIBLE) | ||
| .filter(dao -> dao.getS3CompatibleResponse().getAssumeRole() == null) |
There was a problem hiding this comment.
Nit (not a blocker): The 'plain key pair' decision for s3_compatible is made in two classes
isEndpointOnlyForClient tests getAssumeRole() == null here, and AwsCredentialVendor.vendS3Compatible tests assumeRole != null at :225 to choose between assuming a role and returning the key pair. Both use AwsCredentialGenerator.SESSION_DURATION for the lifetime, and the matrix test and the endpoint-only assume_role test pin both cases, so nothing is wrong today. A new way to get session credentials would need edits in both places.
Cost of keeping it: If a future change gives s3_compatible another session-credential shape and only one site is updated, endpoint-only clients could receive a plain key pair, or have a usable assume_role credential withheld. Credential validation currently rejects the empty-S3AssumeRole case, so this cannot be triggered today.
Optionally add one named predicate, for example a static AwsCredentialVendor.vendsKeyPair(S3CompatibleResponse) or isKeyPairOnly() on the response, and call it from both sites. Keep the decision before the vend so endpoint-only requests still never load the secret.
Evidence
StorageCredentialVendorImpl.java:118-119 (endpoint-only branch): `.expirationTime(
Instant.now().plus(AwsCredentialGenerator.SESSION_DURATION).toEpochMilli())`, and StorageCredentialVendorImpl.java:145-147: `&& credentialDAO
.filter(dao -> dao.getCredentialType() == CredentialType.S3_COMPATIBLE)
.filter(dao -> dao.getS3CompatibleResponse().getAssumeRole() == null)`. The other side, AwsCredentialVendor.java:224-225: `S3AssumeRole assumeRole = s3Compatible.getAssumeRole();
if (assumeRole != null) {`, and AwsCredentialVendor.java:243-244: `return keyPair(credentialDAO, s3Compatible)
.expiration(Instant.now().plus(AwsCredentialGenerator.SESSION_DURATION))`. Both files branch on the same discriminator (assume_role present or not) and compute the same lifetime, and neither calls the other, so the rule lives in two places.
How it was checked
Checked by 2 independent checks: NITPICK
Would a single shared predicate be worth it here, or do you prefer to keep the two checks until a second caller appears?
| s3Endpoint.map( | ||
| endpoint -> | ||
| s3BucketRegions.getS3CompatibleRegion(endpoint, path.toUri().getAuthority())); | ||
| if (isEndpointOnlyForClient(credentialDAO, use)) { |
There was a problem hiding this comment.
Nit (not a blocker): Endpoint-only clients now get a fresh expiration on every request, which may contradict 'clients see no change'
At the base commit the endpoint-only client response came through the cache path, so a repeated request within max-age got the cached expiration. At head this branch returns before the cache with Instant.now().plus(SESSION_DURATION), so each request carries a new refresh hint, later by at most max-age. The reviewers could not settle whether the PR description says clients see no change, because neither could read it. The code behavior is agreed by both. docs/server/configuration.md already says the endpoint-only response is built without the cache.
For example: A client asks for the same path twice within max-age. Before, both responses had the same expiration. Now the second has a later one. The commit messages contain no 'no change' claim, so this only matters if the PR body makes it.
If the PR description says clients see no change, add a sentence saying an endpoint-only client response is now built without the vend cache, so each request carries a fresh now + 1h expiration instead of the cached one.
Evidence
L5 check: “Does every sentence of my description/title map to a hunk? Have I said what I did NOT change?” The PR says “clients see no change.” At StorageCredentialVendorImpl.java:109-120, endpoint-only clients now return a fresh `Instant.now().plus(AwsCredentialGenerator.SESSION_DURATION)` without reaching the cache at line 124. Previously, CachingCloudCredentialVendor.java:106-113 returned `copy(cached.credential())` on a hit, including its earlier expiration.
How it was checked
Checked by 2 independent checks, which split: DISPROVED, NITPICK
Missing fact: Codex said DISPROVED because the quoted note is not in the inputs or the checkout. Opus said NITPICK because the behavior change is real. I read the code and both agree on the behavior. At base 300fde9, the endpoint-only client response came from the cache path (AwsCredentialVendor returned Optional.empty and CloudCredentialVendor filled in the expiration). At head, StorageCredentialVendorImpl.java:109-120 returns before the cache, with Instant.now().plus(SESSION_DURATION). So within max-age a repeated request now gets a later refresh hint, at most max-age later. Evidence against the claim: git log --format=%B 300fde92..HEAD | grep -i 'no change' finds nothing, and docs/server/configuration.md says the endpoint-only response is built without the cache. Neither disprover could read the PR body. One fact settles this: the current PR description text. If it says clients see no change, this is a CONFIRMED docs nit. If it does not, there is nothing to fix.
Could you check whether the current PR description makes that claim, and reword it if it does?
| * no expiry is bounded by the max age alone. Callers always receive a copy, so they cannot change a | ||
| * cached credential. | ||
| * S3-compatible storage, the storage credential's version and its S3 endpoint and region. The | ||
| * server and clients share an entry: what a client receives of it is decided after the cache, in |
There was a problem hiding this comment.
Nit (not a blocker): Cache comments say the client policy runs after the cache, but endpoint-only clients never reach it
The class Javadoc here (and the Key record Javadoc at :140) say what a client receives is decided after the cache, in the storage vendor. For endpoint-only clients StorageCredentialVendorImpl returns at :109-120, before cloudCredentialVendor.vendCredential at :124, so that decision comes before the cache and skips it. The same wording appears in CloudCredentialVendorTest.java:975, where the comment says the client policy applies after the cache and the next line says client requests do not go through the cache. 'Server and clients share an entry' is true only for requests that reach the cache: server, cleanup, static-key client and assume_role client requests.
For example: With the default endpoint-only mode and an s3_compatible credential without assume_role, a CLIENT request returns at StorageCredentialVendorImpl.java:113-120 and never builds a Key. A reader of the Javadoc would expect it to share the server's entry. CloudCredentialVendorTest verifies times(1) over CLIENT, SERVER, CLIENT, which shows the client request skips the cache.
Requests that reach the cache share an entry, whether they come from the server or a client. What a client receives is decided by StorageCredentialVendorImpl outside the cache, and endpoint-only client requests skip the cache.
Evidence
L16 check: “Would a new reader know WHY this exists? Did I update the doc to match new behavior?” CachingCloudCredentialVendor.java:38-39 says “what a client receives of it is decided after the cache”; lines 140-141 repeat that claim. CloudCredentialVendorTest.java:975-976 says “the client policy applies after the cache” while also saying client requests “do not go through the cache.” StorageCredentialVendorImpl.java:109-124 returns endpoint-only responses before calling `cloudCredentialVendor.vendCredential(credentialContext)`.
How it was checked
Checked by 2 independent checks: CONFIRMED
How about rewording the three places the same way, which would also answer the open thread PRRT_kwDOMI92_s641QCd on this Javadoc?
| .s3Region(s3Region.orElse(null))) | ||
| .expirationTime( | ||
| Instant.now().plus(AwsCredentialGenerator.SESSION_DURATION).toEpochMilli()) | ||
| .url(path.toString()); |
There was a problem hiding this comment.
Nit (not a blocker): No test notices if the endpoint-only response loses or changes its url
The endpoint-only early return builds its TemporaryCredentials by hand and sets .url(path.toString()) here. Before this PR every non-local response went through the shared tail that sets the url, and tests asserted it there. The new tests that reach this branch compare only getAwsTempCredentials() and the expiration.
For example: Someone removes .url(path.toString()) from this return, or sets the wrong path. Endpoint-only clients then get credentials with no url or the wrong one, and every test still passes. The only getUrl assertions in CloudCredentialVendorTest are at :170 and :537, and both come through the vend path.
assertThat(credentials.getUrl()).as(c.toString()).isEqualTo(COMPAT_PATH);
Evidence
StorageCredentialVendorImpl.java:120 `.url(path.toString());` ends the endpoint-only early return, which builds its own TemporaryCredentials. In CloudCredentialVendorTest, `testS3CompatibleWithoutAssumeRoleVendsPerServerMode` asserts only `credentials.getAwsTempCredentials()` and `credentials.getExpirationTime()`, and the added endpoint-only loop asserts only `.getAwsTempCredentials()` (`.isEqualTo(use == CredentialUse.CLIENT ? endpointAndRegion : keyPair)`). The only `getUrl()` assertions in that file are at lines 170 and 537, and neither runs the endpoint-only path. The early return builds the response by hand, so removing `.url(...)` at line 120 leaves every test passing.
How it was checked
Checked by 2 independent checks: CONFIRMED
How about adding this line to the per-case loop in testS3CompatibleWithoutAssumeRoleVendsPerServerMode, so it covers the endpoint-only branch and each vended case?
| // from the vend cache, whose max age usually ends it first. What a client may receive of it is | ||
| // decided by the caller (StorageCredentialVendorImpl). | ||
| return keyPair(credentialDAO, s3Compatible) | ||
| .expiration(Instant.now().plus(AwsCredentialGenerator.SESSION_DURATION)) |
There was a problem hiding this comment.
Nit (not a blocker): The STS SESSION_DURATION constant now also sets the key pair refresh interval and cache cap
Key pair vends now carry expiration = now + AwsCredentialGenerator.SESSION_DURATION, and the endpoint-only response in StorageCredentialVendorImpl repeats the same arithmetic. For clients this predates the PR, but server and cleanup key pair vends now also carry the value, which caps cache reuse and is written to audit expires_at. The field then means a real deadline for assume_role, Azure and GCP, and a refresh hint here. The comment at :238-241 documents this, and the matrix test pins both sites to 1h.
Cost of keeping it: Someone changes SESSION_DURATION for STS reasons. The key pair refresh cadence, the audit expires_at and the cache cap change with it, and nothing in the types shows they were tied together. No caller gets a wrong result today.
static final Duration KEY_PAIR_REFRESH_INTERVAL = AwsCredentialGenerator.SESSION_DURATION;
Evidence
StorageCredentialVendorImpl.java:118-119: `.expirationTime(Instant.now().plus(AwsCredentialGenerator.SESSION_DURATION).toEpochMilli())`. AwsCredentialVendor.java:244: `.expiration(Instant.now().plus(AwsCredentialGenerator.SESSION_DURATION))` with the comment "The key pair itself does not expire." Both sites invent an expiry for something that does not expire, and both borrow an STS constant for it. The same field now means "the credential dies at T" for assume_role and Azure/GCP, and "fetch again around T" for a key pair.
How it was checked
Checked by 2 independent checks, which split: DISPROVED, NITPICK
How about naming the interval once and using it at AwsCredentialVendor.java:243 and StorageCredentialVendorImpl.java:118?
timothyw553
left a comment
There was a problem hiding this comment.
no blockers here, looks clean overall. merge once it is addressed.
| externalLocationUtils, | ||
| serverProperties, | ||
| s3BucketRegions); | ||
| for (CredentialUse use : List.of(CredentialUse.SERVER, CredentialUse.CLIENT)) { |
There was a problem hiding this comment.
this only asserts getAwsTempCredentials() so it discards expirationTime -- shouldn't we also check that the cached response has the 1-hour expiry and returns the same timestamp on the cache hit? also might be cleaner to split the uncached matrix, shared-cache case, and endpoint-only bypass into separate tests so the third case doesn't depend on stubs from the second.
… on the external location (#2289) ## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2289/files) to review incremental changes. - [**stack/s3compat_location_endpoint**](#2289) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2289/files)] ← _this PR_ - [stack/s3compat_external_location_id](#2395) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2395/files/279e4214f62311816d4cec93fd0150a021d5f495..8a58c1528404e758093091408a9a4266eeb581e4)] --------- Finalizes S3-compatible storage, which the stack #2170 to #2175 and #2169 (all merged) built. **Description of changes** **Why.** The S3 endpoint belongs to the storage a location is on, not to the key pair that reaches it. With the endpoint on the credential, one credential could not serve locations on several storage hosts, and moving a bucket to a new host meant editing the credential. This PR moves the endpoint, and whether its requests are path-style, to the external location. The vend returns the location's settings beside the keys, so a client always gets the endpoint, region and addressing style that match the keys it signs with. It also takes the feature out of experimental status. **API** (`api/all.yaml`, `api/delta.yaml`, regenerated `api/` docs) Storage credential and external location: ```json {"name": "aistor_cred", "purpose": "STORAGE", "s3_compatible_access_key": {"access_key_id": "uc-user", "secret_access_key": "...", "sts_endpoint": "https://sts.example.com", "role_arn": "arn:aws:iam:::role/uc-tables"}} {"name": "aistor_loc", "url": "s3://sales/tables", "credential_name": "aistor_cred", "endpoint": "https://aistor.example.com", "path_style_access": true} ``` Vended credentials (`TemporaryCredentials`): ```json {"aws_temp_credentials": {"access_key_id": "...", "secret_access_key": "...", "session_token": "..."}, "expiration_time": 1764200000000, "external_location_settings": { "s3_compatible": {"endpoint": "https://aistor.example.com", "region": "us-east-1", "path_style_access": true}}} ``` - The credential field `s3_compatible` is renamed `s3_compatible_access_key` (`S3CompatibleAccessKeyRequest`/`Response`). It holds the keys plus the optional flat STS fields `sts_endpoint` and `role_arn`. `s3_endpoint`, the nested `assume_role` (`S3AssumeRole`) and `sts_region` are removed. - `CreateExternalLocation`, `UpdateExternalLocation` and `ExternalLocationInfo` get `endpoint` (`http[s]://host[:port]`, at most 2048 characters, without a path) and `path_style_access` (boolean). `UpdateExternalLocation.path_style_access` has its own description: it needs a stored `endpoint`, and leaving it out keeps the stored value. - A location's `endpoint` and a credential's `sts_endpoint` are stored, returned and vended with the scheme and host in lowercase. The `sts_endpoint` text states the same `http[s]://host[:port]` form, and `updateExternalLocation` says which rules fail with `INVALID_ARGUMENT`. - The schemas carry the server's limits: `maxLength: 2048` on the endpoint, `minLength: 1` on the keys, and `pattern: '^arn:'` on `role_arn`. Vended credentials carry the location's `endpoint`; a credential's `sts_endpoint` is only where the server calls STS, and is never vended. - `ui/src/types/api/catalog.gen.ts` is regenerated from `api/all.yaml`, which also picks up earlier spec changes it was missing (`browse_only`, `include_browse`, the required `purpose`). - `TemporaryCredentials` gets `external_location_settings` (`ExternalLocationSettings`), set exactly when the path is on S3-compatible storage. It has `s3_compatible` (`endpoint`, `region`, `path_style_access`). `AwsCredentials` carries only keys again: `s3_endpoint` and `s3_region` are removed. An endpoint-only vend returns the settings and `expiration_time` without `aws_temp_credentials`. - Delta API: the credential `config` key map carries `s3.endpoint`, `client.region` and `s3.path-style-access`, the same keys the Iceberg REST config uses. - No "EXPERIMENTAL" labels remain on S3-compatible storage. - `spec/protocols/ManagedDeltaTablesSpec.md` matches `api/delta.yaml`: the config carries `s3.endpoint`, `client.region` and the boolean `s3.path-style-access`, so its values are strings or a boolean, and a false or absent `s3.path-style-access` means virtual-hosted. **Rules** - A location has an `endpoint`, and may have `path_style_access`, exactly when it is on S3-compatible storage: required with an `s3_compatible_access_key` credential, refused with another, and kept after its credential is force-deleted. An update that leaves either out keeps the stored value. - A missing or false `path_style_access` means virtual-hosted. Then the bucket name must be a host name label: 3 to 63 lowercase letters, digits and hyphens, a letter or digit at both ends, and no dots, since a dot breaks wildcard TLS certificates. Create and update refuse other names and name the bucket. `ExternalLocationInfo` always returns `path_style_access` when the location has an `endpoint`. - STS is on when `role_arn` is set. It holds the ARN of the role to assume, for example `arn:aws:iam:::role/uc-tables`, sent unchanged as AssumeRole's `RoleArn`; a value that doesn't start with `arn:` is refused. Storage that ignores the role, such as MinIO, still needs an ARN-shaped value. `sts_endpoint` is allowed only with `role_arn`. Without it, AssumeRole goes to the location's endpoint, signed with the bucket region the server detects. - A location keeps its storage kind, which its stored `endpoint` decides, also after its credential was force-deleted. A location with an endpoint can only get another `s3_compatible_access_key` credential; one without can get neither an endpoint, nor `path_style_access`, nor such a credential. Moving a location to other storage means deleting it and creating a new one, so an update can't clear `endpoint` or `path_style_access`. A credential's type can't change while a location uses it; new keys or a new role can. - Changing `endpoint` or `path_style_access` of a location in use is refused unless `force` is set, with the same in-use check as a URL change. Resending the stored value isn't a change, and neither is an `endpoint` that differs only in the case of its scheme or host. - A location whose credential was force-deleted still checks its own settings on update: the endpoint form and length, the `s3://` URL, and the bucket rule for virtual-hosted addressing. Vending under it fails until it is repaired. **Server** - Schema steps `V20__external_location_endpoint` (nullable `varchar(2048)`) and `V21__external_location_path_style_access` (nullable boolean, `bit` on MySQL), with their effect files. A virtual-hosted location stores `false`, so the column is null exactly without an endpoint. - `ExternalLocationUtils.getExternalLocationCredentialForPath` returns the location together with its credential, read from one snapshot (`TransactionManager.snapshotIsolation`: REPEATABLE READ on PostgreSQL and MySQL, SERIALIZABLE on H2), so a vend never pairs a location with a credential from another committed state. A location of an `s3_compatible_access_key` credential without an endpoint fails the vend with `INTERNAL`, so keys are never sent to AWS S3 by mistake. - The location's endpoint, detected region and path style travel through `CredentialContext` and the vend cache key into `external_location_settings`; the `endpoint-only` client response, built after the cache in `StorageCredentialVendorImpl`, carries the same settings; the Iceberg REST config (`s3.endpoint`, `client.region`, `s3.path-style-access`) and the Delta config. Region discovery addresses the bucket as the location says. - The server property `server.s3-compatible-storage.enabled` is removed, with every guard that read it. The encryption key `server.credential-encryption-key` is now read whenever it's set: a malformed key refuses startup. Without a key, creating or updating an `s3_compatible_access_key` secret fails with `FAILED_PRECONDITION`, while stored credentials stay readable, renamable and deletable. `server.s3-compatible-storage.static-key-vending` is unchanged. **Clients** - Hadoop connector: reads the endpoint, region and path style from `external_location_settings.s3_compatible`. Settings that are absent mean AWS S3, and a missing `path_style_access` means virtual-hosted. It sets `fs.s3a.bucket.<bucket>.path.style.access`, records the style per bucket and in the file system cache id, and renewal refuses a changed style just as it refuses a changed endpoint. - CLI: - `credential create`/`update`: `--s3_endpoint` and `--s3_sts_region` are removed, and `--s3_role_arn` sets `role_arn`. - `external_location create`/`update`: new `--endpoint` and `--path_style_access`. - The Delta Kernel path reads the location's settings. - `docs/usage/cli.md` documents `--endpoint` and `--path_style_access` on `external_location create`/`update`, and that `--force` also covers an endpoint or path-style change on a location in use. - Docs, Helm and `etc/conf/server.properties` use the new names and no longer mention the enable property. The chart needs only `server.credentialEncryptionKeySecret`, and the Helm CI install case passes only the key Secret. **Tests** - External location CRUD (SDK and CLI): the endpoint rules and forms (including an over-long one), one credential on two endpoints, the storage-kind refusals, key and role changes of credentials in use, endpoint and path-style changes while in use (with and without `force`), locations whose credential was force-deleted, and `path_style_access` defaults, updates and the bucket-name rule. - Vending under an S3-compatible location whose credential was force-deleted fails, and works again after repair. - Mixed-case `endpoint` and `sts_endpoint` values on create and update are stored, returned and vended lowercased, and a case-only `endpoint` edit on a location in use needs no `force`. - Region discovery for one bucket on one endpoint with both addressing styles: `forcePathStyle(true)` and `forcePathStyle(false)`, cached apart. - Credential CRUD and DAO: `role_arn` and `sts_endpoint` validation. - Vending, unit and on real storage: the settings for STS sessions, static keys and endpoint-only vends. AssumeRole gets the role's ARN, the detected region, and the location endpoint as fallback. - The cache key includes the path style. - The Iceberg and Delta configs, for both path-style values. - AWS S3 credentials from the UC API, the Delta API and the constructors are equal: the path style is only kept with an endpoint, and a missing flag is virtual-hosted. - The cached credential id (`FileSystemCredId.create(Configuration)`) differs by endpoint, region and path style. - Connector and CLI settings, including renewal refusing a changed style, a bucket whose two paths differ only in style, and a cached credential not shared across styles. Both new connector tests fail when the style check or the `pathStyle.` key of the cache id is removed. - Secret store and repository behavior without a key or with a malformed one. - The real-storage harness reaches its containers at `127.0.0.1` ports, so its locations set `path_style_access: true`. Virtual-hosted addressing isn't run against real storage. Follow-ups: `external_location_id` in `ExternalLocationSettings` (#2395, stacked on this PR); `ExternalLocationSettings` entries for other storage types: `s3` (with `region`), `adls` and `gcs`. **Compatibility.** S3-compatible storage hasn't been released, so these API, property and CLI changes need no compatibility shim, and no data is migrated. Credentials, locations and vends for other storage are unchanged. **Tests run** on the final head, rebased onto main with #2268, #1928 and #2394: - `io.unitycatalog.server.migrate.*` with `UC_TEST_MIGRATION_CHECKS=true` on H2, PostgreSQL 18 and MySQL 8: 241 tests each. - `dev/run-tests.py`, full suite on H2: 4,085 tests. - The server suite on PostgreSQL 18 and on MySQL 8: 1,779 tests each. - On MinIO (`UC_TEST_STORAGE=MINIO`): the S3-compatible, external location and credential tests plus `spark/test`, 576 tests. - The Hadoop connector tests (1,530), on the head before the last rebase. - The Helm workflow's lint and render checks, and `helm/README.md` regenerated with helm-docs v1.14.2. - Regenerating the API docs and the UI types leaves no diff; `yarn test:format` passes in `ui/`, and `tsc --noEmit` reports no errors outside `node_modules`, as before. On an earlier head, before the endpoint length limit: the S3-compatible tests plus `spark/test` on Garage (555). 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]>
PR Checklist
docsis updatedDescription of changes
What a client may receive of an
s3_compatiblekey 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:static-keyclient got the key pair with a one-hour refetch timeendpoint-onlyclient got only the endpoint and regionisServerAccess, and server and client vends of one credential never shared an entryChanges:
AwsCredentialVendoralways vends the key pair with the one-hour refetch time, for every caller; it no longer readsserver.s3-compatible-storage.static-key-vendingCachingCloudCredentialVendorkey dropsisServerAccess, so the server, the cleanup andstatic-keyclients share one entryStorageCredentialVendorImplapplies the client policy: anendpoint-onlyclient, on ans3_compatiblecredential withoutassume_role, gets only the endpoint and region, with the same lifetime, built there without vending, so its secret is still never loadedCredentialContext.isServerAccessand the empty-vend branch ofCloudCredentialVendorhave no users left and are removedCredential 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:
CloudCredentialVendorTestdefaults to theendpoint-onlymode, and theassume_roletest runs in it, so the guard that letsassume_rolecredentials vend sessions to clients is coveredisEndpointOnlyForClientuses an exhaustiveswitchonPurpose, so a new purpose has to chooseexpires_atof 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-onlyresponses carry it without the cacheCloudCredentialVendorTest.testS3CompatibleWithoutAssumeRoleVendsPerServerModealso checks, behind the vend cache inendpoint-onlymode, that a client never gets the key pair the server's vend cached, and that its requests skip the cacheCloudCredentialVendorTest.testS3CompatibleWithoutAssumeRoleVendsPerServerModeexpects the lifetime for every use, and checks that a server and astatic-keyclient share one cached vend (the secret is loaded once)CachingCloudCredentialVendorTestdrops the two cases about server and client entries; distinct credential versions stay covered bychangedBindingsbuild/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_compatiblekey pair now carry the one-hour lifetime too. For them it only caps reuse from the vend cache, whichserver.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 asexpires_at; clients see no change.This pull request and its description were written by Isaac.