feat: ship an S3 credential provider that refreshes Iceberg REST-vended credentials #7363
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 616 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.384
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7363"
general
weight: 0.35
comphead
Which issue does this PR close?
Closes #7387.
Closes #7388.
#7389 (Spark 3.x) stays open; the docs say the provider is Spark 4.x only.
Depends on #7464, which closes superseded providers (#7390) and should merge first: automatic selection gives every REST catalog table a provider with an HTTP client. Until it merges, this PR's diff includes its two commits. The provider changes are the last three commits.
Rationale for this change
The native Iceberg scan signs S3 requests with the
s3.*credentials an Iceberg REST catalog vended when the driver loaded the table. Those credentials are short-lived (about an hour on Unity Catalog), so a scan still running after they expire fails withExpiredToken. Vanilla Spark on the same table keeps working, because Iceberg'sS3FileIOrefreshes the credentials from the endpoint the catalog returns inclient.refresh-credentials-endpoint.The S3 credential SPI (#4309, #6509) lets a provider do the same, and the docs pointed at
IcebergRESTVendedS3Provideras the reference to copy. That reference builtVendedCredentialsProviderstraight from the FileIO properties, which needscredentials.uri. A REST catalog returns the endpoint underclient.refresh-credentials-endpoint, andS3FileIOreaches it throughAwsClientProperties, which maps it to the URI and also carries the catalog URI and OAuth properties. So the reference never refreshed against a real REST catalog.What changes are included in this PR?
IcebergVendedS3CredentialProvider(Spark 4.x, main scope).initializehands the FileIO bag to Iceberg'sAwsClientProperties.credentialsProvider(...)and gets back the providerS3FileIOwould use: aVendedCredentialsProviderwhen the catalog returned a refresh endpoint, the static vended keys otherwise, and the default chain when neither is set. Iceberg is loaded by reflection from the context class loader, so Comet gains no compile-time Iceberg dependency.- Credentials go through
SdkCredentialExtraction, so blank keys (for example from an anonymousclient.credentials-provider) fail with a clear error instead of a later 403.- Static vended keys report
s3.session-token-expires-at-msas their expiry, so Comet keeps reusing them until shortly before they expire.- A missing iceberg-aws, a failure inside Iceberg, a missing AWS SDK, and two copies of the SDK under
userClassPathFirsteach get their own error message.CometIcebergNativeScan.withVendedCredentialProvider). Comet selects this provider when all of these hold:- the FileIO properties carry
client.refresh-credentials-endpoint, and refresh isn't disabled;- the endpoint is absolute, or the properties carry the catalog
uriit resolves against;- no provider is configured. An explicit
s3.comet.credential.provider.classtakes precedence, and an empty value opts out;- on the driver, the provider class loads and Comet's loader and the context loader see one AWS SDK v2. This is checked once per JVM. Otherwise a provider that can't initialize would fall back to the default chain, and log, on every task.
requireSupportedS3FileIOPropertiesrejectsclient.refresh-credentials-endpoint, so such a write falls back to Spark, and the docs say so.IcebergRESTVendedS3Providerand its test.s3-credential-providers.mddescribes the provider, automatic selection, the opt-out and the Spark 4.x limit.iceberg.mdno longer says the native reader ignores vended credentials.s3-credential-provider-design.mdlists three SPI implementations.How are these changes tested?
Run locally with
-Pspark-4.0on JDK 17, on top of the lifecycle branch:IcebergVendedS3CredentialProviderTest(10 tests) runs a local HTTP server standing in for the catalog's/v1/credentialsendpoint, so refresh goes through Iceberg's realVendedCredentialsProvider. It covers refresh, reuse, static keys, disabled refresh, no token, a relative endpoint resolved againsturi, an Iceberg failure unwrapped fromInvocationTargetException, a missing iceberg-aws, anonymous credentials, and the reported expiry of static vended keys.CometIcebergNativeScanSuitecovers selection, precedence, the opt-out, a relative endpoint with and withouturi, and the public overload, so a wrongVendedCredentialProviderClassfails.CometIcebergNativeSuiteaddsREST catalog refresh endpoint selects the vended provider for the native scan. It plans and runs a native scan against a REST catalog that returns a refresh endpoint, and checks the provider key in the serialized catalog properties: the provider on Spark 4.x, absent on 3.x.CometS3CredentialBridgeSuite(10 tests, MinIO) andCometS3CredentialDispatcherTest(21 tests) pass.🤖 Generated with Claude Code