← Back to Pull requests

feat: ship an S3 credential provider that refreshes Iceberg REST-vended credentials #7363

Open
unknown opened this pull request with 616 lines diff across 7 files
View on GitHub
unknown unknown commented on Oct 31, 2026 16:37 UTC
Author

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 with ExpiredToken. Vanilla Spark on the same table keeps working, because Iceberg's S3FileIO refreshes the credentials from the endpoint the catalog returns in client.refresh-credentials-endpoint.

The S3 credential SPI (#4309, #6509) lets a provider do the same, and the docs pointed at IcebergRESTVendedS3Provider as the reference to copy. That reference built VendedCredentialsProvider straight from the FileIO properties, which needs credentials.uri. A REST catalog returns the endpoint under client.refresh-credentials-endpoint, and S3FileIO reaches it through AwsClientProperties, 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). initialize hands the FileIO bag to Iceberg's AwsClientProperties.credentialsProvider(...) and gets back the provider S3FileIO would use: a VendedCredentialsProvider when 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 anonymous client.credentials-provider) fail with a clear error instead of a later 403.
    - Static vended keys report s3.session-token-expires-at-ms as 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 userClassPathFirst each get their own error message.
  • Automatic selection for native scans (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 uri it resolves against;
    - no provider is configured. An explicit s3.comet.credential.provider.class takes 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.
  • The native writer doesn't select it. requireSupportedS3FileIOProperties rejects client.refresh-credentials-endpoint, so such a write falls back to Spark, and the docs say so.

  • Removed: the test-scope IcebergRESTVendedS3Provider and its test.

  • Docs: s3-credential-providers.md describes the provider, automatic selection, the opt-out and the Spark 4.x limit. iceberg.md no longer says the native reader ignores vended credentials. s3-credential-provider-design.md lists three SPI implementations.
  • How are these changes tested?

    Run locally with -Pspark-4.0 on JDK 17, on top of the lifecycle branch:

  • IcebergVendedS3CredentialProviderTest (10 tests) runs a local HTTP server standing in for the catalog's /v1/credentials endpoint, so refresh goes through Iceberg's real VendedCredentialsProvider. It covers refresh, reuse, static keys, disabled refresh, no token, a relative endpoint resolved against uri, an Iceberg failure unwrapped from InvocationTargetException, a missing iceberg-aws, anonymous credentials, and the reported expiry of static vended keys.

  • CometIcebergNativeScanSuite covers selection, precedence, the opt-out, a relative endpoint with and without uri, and the public overload, so a wrong VendedCredentialProviderClass fails.

  • CometIcebergNativeSuite adds REST 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) and CometS3CredentialDispatcherTest (21 tests) pass.
  • 🤖 Generated with Claude Code

    Diff: 616 lines (+462 / -154) across 7 files Reviewer: comphead Review duration: 6188m
    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
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.2% (MEDIUM) · Higher = larger blast radius
    50.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.8% · Safe to merge
    26.8%