Repository navigation
[Hadoop] Give each fixed credential its own credential-scoped file system - #2305
Merged
yili-db merged 1 commit intoNov 19, 2026
Merged
Conversation
…stem With renewCredential.enabled=false, every table or path load vends a fresh fixed credential, but CredScopedFileSystem cached its delegate by a key that did not include the credential. Later loads reused the delegate built with the first load's credential, so once that expired every query on the table failed until the JVM restarted or the delegate was evicted. The props builder now records a hash of the fixed credential keys it sets in fs.unitycatalog.fixed.credential.id when credential-scoped file systems are on, and FileSystemCredId includes it. A load with a new credential gets its own delegate, loads that share a credential still share one, and the old delegate is closed through the existing eviction and lease logic. Signed-off-by: Maha Rana Yadavalli <[email protected]>
maharanay22
requested review from
openinx,
tdas,
timothyw553 and
yili-db
as code owners
November 19, 2026 18:14
Collaborator
|
/review |
yili-db
approved these changes
Nov 19, 2026
yili-db
left a comment
Collaborator
There was a problem hiding this comment.
[AI Assisted] Approve. The fixed-credential file system key looks right, and the reload tests fail without it on all three clouds.
4 tasks done
yili-db
pushed a commit
that referenced
this pull request
Nov 23, 2026
…ed (#2323) **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! - [x] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** With credential renewal disabled (`renewCredential.enabled=false` in Spark, or `enableCredentialRenewal(false)` in `UCCredentialHadoopConfs`), GCS tables and paths don't use the token Unity Catalog vends. The props builder writes the token to `fs.gs.auth.access.token.credential` and `fs.gs.auth.access.token.expiration`, but no class in the GCS connector reads those keys, and `fs.gs.auth.type` is never set. The connector then falls back to its default Compute Engine credentials. For example, reading a GCS table from a laptop with renewal off fails because the metadata server can't be found, and on a GCE VM the same read silently runs as the VM's service account instead of the table-scoped token. S3 doesn't have this problem because S3A's default providers read the fixed keys, and Unity Catalog records when an engine provider overrides them. GCS has no provider chain, so the table's auth type has to be set. This regressed in #1137, which replaced the provider that read those keys with the renewable one and kept the auth keys only on the renewal path. The fixed path now also sets `fs.gs.auth.type=ACCESS_TOKEN_PROVIDER` with a new `GcsFixedTokenProvider`. It serves the vended token with its expiration and never renews it. Like the renewal path, this overrides a session-wide `fs.gs.auth.type` for that table only. The provider #1137 removed always threw from `refresh()`, while the new one only throws once the token has expired, which keeps the token in use during the few minutes before expiry when the connector refreshes early. After that the refresh fails with an error that says to load the table or path again or to enable credential renewal. The provider reads its clock the same way `GenericCredentialProvider` does. The two auth keys are constant, so the fixed credential id from #2305 still changes only with the token and its expiry, and a new token still gets its own credential-scoped file system. Users who ran with renewal off and relied on the VM or application default identity for Unity Catalog tables will now use the vended token instead. The streaming checkpoint note in `docs/integrations/unity-catalog-spark.md` said Unity Catalog sets its own GCS auth type only with renewal. It now says it does so for each table or path it vends a token for, apart from one that gets several tokens while renewal is off, and it names `spark.sql.catalog.<name>.renewCredential.enabled=false`. In that case no credential keys are set for any cloud, which predates this change and is left for a follow-up. **Tests** `GcsCredPropsTest.gcsConnectorAuthenticatesWithTheVendedToken` runs the built props through the connector's own `HadoopCredentialsConfiguration.getCredentials` with renewal on and off, with and without an expiration, with credential-scoped file systems on, and from a configuration that already sets `fs.gs.auth.type=APPLICATION_DEFAULT`. It checks that the connector sends the vended token and reports its expiration. On `main` every renewal-off row fails and resolves to Compute Engine credentials. `fixedTokenIsUsedUntilItExpires` uses a manual clock to check that a fixed token is still sent one millisecond before its expiration and that the refresh fails at exactly the expiration. Making the refresh never fail, always fail, fail only after the expiration, or ignore the expiration or the clock each makes a test fail, Dropping the two auth keys failed 68 tests before the `APPLICATION_DEFAULT` rows were added, and dropping only `fs.gs.auth.type` from the fixed path makes the renewal-off `APPLICATION_DEFAULT` row fail because the connector looks for Application Default Credentials. The tests run against the unshaded `HadoopCredentialsConfiguration` from util-hadoop 3.0.2, while production uses the shaded copy of the same version in the GCS connector. The expiry failure was not checked end to end against a real `GoogleHadoopFileSystem` or a GCS bucket. On Windows with JDK 17, `GcsCredPropsTest`, `S3CredPropsTest`, `AzureCredPropsTest`, `CredPropsRoundTripTest` and the `id` tests pass, and at the current head the full `hadoop/test` (1528 tests) and the hadoop format checks pass. The Spark integration tests run in CI. --------- Signed-off-by: Maha Rana Yadavalli <[email protected]> Co-authored-by: Maha Rana Yadavalli <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
docsis updatedDescription of changes
With
renewCredential.enabled=falseand credential-scoped file systems on (the default), every table or path load vends a new fixed credential, butCredScopedFileSystemcaches its delegate under aFileSystemCredIdthat leaves the credential out. For AWS S3 with vended keyss3Storageis empty, and the Azure and GCS ids never include the token. So every later load is served by the delegate built with the first load's credential. Once that credential expires, about an hour later, every query on the table fails with an expired token until the JVM restarts or the delegate is evicted from the cache. With renewal on, the delegate's token provider renews the credential itself, so only the fixed path is affected.The props builder now records a SHA-256 hash of the fixed credential keys it sets, never the keys themselves, as
fs.unitycatalog.fixed.credential.idwhen credential-scoped file systems are on, andFileSystemCredIdincludes it inequalsandhashCodebut not intoString. A load with a new credential gets its own delegate, and loads that share a credential, such as two loads served frominitialCredCache, still share one. The old delegate is closed through the existing eviction and lease logic once nothing uses it. This is the same idea S3-compatible fixed keys already use, since they are hashed intos3Storage. To keep each cloud's builder the only place that knows which keys carry the credential,setInitFixedCredKeysbecameinitFixedCredKeys, which returns the keys forbuild()to set and hash.One assertion in
S3CredPropsTest.severalCredentialsWithoutKeysLeaveTheEngineKeysInUseexpected the next load's fixed keys to get the same id as the first load's. That is the case this PR changes, so it now expects a different id, while two users of one credential still share an id.docs/doesn't describerenewCredential.enabledor credential-scoped file systems, so there is nothing to update there.Tests
CredPropsRoundTripTest.reloadWithoutRenewalUsesFreshlyVendedCredentialloads a table twice without renewal, with a different credential each time, and checks for S3, Azure and GCS that the second load's delegate carries the second credential while the first load's configuration still gets its original delegate. It fails onmainfor all three clouds with the first credential.reloadWithoutRenewalOfTheSameCredentialReusesDelegatechecks that two loads of the same credential share one delegate. Leaving the id out ofFileSystemCredId, not setting it in the builder, ignoring it inequals, or hashing a constant each make a test fail.build/sbt "hadoop/test"passes (1520 tests) on Windows with JDK 17, and so dohadoop/javafmtCheckAllandhadoop/Test/javafmtCheckAll.