Skip to content

[Server] Return the external location id in vended credential settings - #2395

Draft
yili-db wants to merge 1 commit into
unitycatalog:mainfrom
yili-db:stack/s3compat_external_location_id
Draft

yili-db wants to merge 1 commit into
unitycatalog:mainfrom
yili-db:stack/s3compat_external_location_id

Conversation

@yili-db

@yili-db yili-db commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #2289 (merged), now based on main.

Description of changes

Vended credential settings now carry the id of the external location they come from, so it's clear which location an ExternalLocationSettings belongs to.

What

  • API: ExternalLocationSettings gets external_location_id, the id of the external location these settings come from. Regenerated api/ docs.
  • Server:
    • CredentialContext carries the location's id, which StorageCredentialVendorImpl fills in from the location found for the path. Every vend with external_location_settings returns it, including endpoint-only vends without keys.
    • The vend cache key includes the id, so a location recreated at the same URL vends its new id rather than a cached one.

Tests

  • CloudCredentialVendorTest: the id in the settings of every S3-compatible vend.
  • CachingCloudCredentialVendorTest: a different location id is a different cache key.
  • SdkExternalLocationCRUDTest: two locations sharing one credential each vend their own id.
  • S3CompatibleCredentialVendingTest (real storage): each vend names the location.

Tests run on this head:

  • dev/run-tests.py, full suite on H2: 4,086 tests.
  • The vend, credential and external location test classes, server (195) and CLI (21), on the previous head; the credential vendor tests (129) again after the rebase.

Compatibility. An additive output field: external_location_settings gains external_location_id, and clients that don't read it are unaffected. No request field, property or schema change.

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 Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_external_location_id branch from c0339a0 to 570b51d Compare December 1, 2026 06:53
@yili-db

yili-db commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_external_location_id branch from 570b51d to 2fc9f41 Compare December 1, 2026 07:33
@yili-db

yili-db commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db

yili-db commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_external_location_id branch from ece2ee4 to fe708e0 Compare December 2, 2026 07:35
@yili-db

yili-db commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db
yili-db force-pushed the stack/s3compat_external_location_id branch from fe708e0 to 8a58c15 Compare December 2, 2026 09:23
@yili-db

yili-db commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

/review

yili-db added a commit that referenced this pull request Dec 2, 2026
… 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]>
- `ExternalLocationSettings` gets `external_location_id`, the id of the external location these settings come from
- `CredentialContext` carries the id of the location covering the path, filled in by `StorageCredentialVendorImpl`, including for endpoint-only vends
- The vend cache key includes the id, so a location recreated at the same URL vends its new id
- Tests: the id in unit and real-storage vends, two locations sharing a credential, and the cache key

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
@yili-db
yili-db force-pushed the stack/s3compat_external_location_id branch from 8a58c15 to 51bcaed Compare December 2, 2026 17:31

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant