Repository navigation
[Hadoop] Serve the vended GCS token when credential renewal is disabled - #2323
Conversation
With renewal disabled, the GCS props set only fs.gs.auth.access.token.credential and fs.gs.auth.access.token.expiration, which no class in the GCS connector reads, and left fs.gs.auth.type unset. The connector then fell back to its default Compute Engine credentials, so table and path access failed off GCE and ran as the VM's service account on GCE. The fixed path now also sets fs.gs.auth.type=ACCESS_TOKEN_PROVIDER with the new GcsFixedTokenProvider, which serves the vended token with its expiration and never renews it. Once the token expires, its refresh fails with an error that says to load the table or path again or enable credential renewal. Signed-off-by: Maha Rana Yadavalli <[email protected]>
|
/review |
timothyw553
left a comment
There was a problem hiding this comment.
production code looks good. i left a couple comments on test coverage and docs, plus one small nit on validation.
| `spark.hadoop.fs.gs.auth.type=APPLICATION_DEFAULT`). With the default renewing credentials, Unity Catalog sets its own | ||
| auth type for each table, so that session-wide setting only applies to locations Unity Catalog does not vend for, such | ||
| as the checkpoint. | ||
| `spark.hadoop.fs.gs.auth.type=APPLICATION_DEFAULT`). Unity Catalog sets its own auth type for each table it vends a |
There was a problem hiding this comment.
does this apply to vended paths too, not just tables? also could we name spark.sql.catalog.<name>.renewCredential.enabled=false so readers know which setting disables renewal?
There was a problem hiding this comment.
Yes, path credentials use the same props builder, so it applies to paths too. Done in c918ee3: the note now says table or path and names spark.sql.catalog..renewCredential.enabled=false.
…al setting Signed-off-by: Maha Rana Yadavalli <[email protected]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Comment. The docs update is accurate. Approve-worthy once the APPLICATION_DEFAULT row is added: the PR states this override and no test exercises it. Hadoop tests pass, and reverting the fixed-path wiring fails the 68 tests the description names.
| */ | ||
| @ParameterizedTest(name = "renew={0} credScoped={1} expiring={2}") | ||
| @CsvSource({ | ||
| "false, false, false", |
There was a problem hiding this comment.
[AI Assisted] The PR says the fixed path overrides a session-wide fs.gs.auth.type (the checkpoint docs use APPLICATION_DEFAULT for exactly this case), but no row starts from a configuration that already sets it. Could we add a row that sets fs.gs.auth.type=APPLICATION_DEFAULT before the built props are applied, and assert AccessTokenProviderCredentials with the vended bearer value?
There was a problem hiding this comment.
Added two rows starting from fs.gs.auth.type=APPLICATION_DEFAULT in a442c57. Dropping the fixed auth type makes the renewal-off row fail.
| this.accessToken = | ||
| new AccessToken( | ||
| conf.get(ACCESS_TOKEN_KEY), | ||
| Instant.ofEpochMilli(conf.getLong(ACCESS_TOKEN_EXPIRATION_KEY, Long.MAX_VALUE))); |
There was a problem hiding this comment.
[AI Assisted] Nit: Long.MAX_VALUE as the no-expiration value is written by GcsCredPropsBuilder and read back here as the default. A shared constant would keep the two in step.
There was a problem hiding this comment.
Done in a442c57. GcsFixedTokenProvider.NO_EXPIRATION_MILLIS is now shared by the builder and the provider.
| try { | ||
| Configuration conf = new Configuration(false); | ||
| conf.set(UCHadoopConfConstants.UC_TEST_CLOCK_NAME, clockName); | ||
| Instant expiration = clock.now().plusSeconds(60).truncatedTo(ChronoUnit.MILLIS); |
There was a problem hiding this comment.
[AI Assisted] Nit: the 60 second expiry is deliberately inside google-auth's expiration margin, so each request goes through refresh(). A short comment here would stop a later margin change from looking like a provider bug.
There was a problem hiding this comment.
Added a short comment in a442c57 explaining that 60 seconds sits inside google-auth's expiration margin, so every request calls refresh().
…ntials Signed-off-by: Maha Rana Yadavalli <[email protected]>
…uth type Signed-off-by: Maha Rana Yadavalli <[email protected]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Approve. The earlier points are addressed: the session-wide APPLICATION_DEFAULT rows catch a regression in the fixed auth type, the expiration constant is shared, and the 60 second comment is in place. Hadoop tests pass, and reverting the fixed-path wiring fails the GCS tests.
PR Checklist
docsis updatedDescription of changes
With credential renewal disabled (
renewCredential.enabled=falsein Spark, orenableCredentialRenewal(false)inUCCredentialHadoopConfs), GCS tables and paths don't use the token Unity Catalog vends. The props builder writes the token tofs.gs.auth.access.token.credentialandfs.gs.auth.access.token.expiration, but no class in the GCS connector reads those keys, andfs.gs.auth.typeis 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_PROVIDERwith a newGcsFixedTokenProvider. It serves the vended token with its expiration and never renews it. Like the renewal path, this overrides a session-widefs.gs.auth.typefor that table only. The provider #1137 removed always threw fromrefresh(), 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 wayGenericCredentialProviderdoes. 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.mdsaid 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 namesspark.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.gcsConnectorAuthenticatesWithTheVendedTokenruns the built props through the connector's ownHadoopCredentialsConfiguration.getCredentialswith renewal on and off, with and without an expiration, with credential-scoped file systems on, and from a configuration that already setsfs.gs.auth.type=APPLICATION_DEFAULT. It checks that the connector sends the vended token and reports its expiration. Onmainevery renewal-off row fails and resolves to Compute Engine credentials.fixedTokenIsUsedUntilItExpiresuses 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 theAPPLICATION_DEFAULTrows were added, and dropping onlyfs.gs.auth.typefrom the fixed path makes the renewal-offAPPLICATION_DEFAULTrow fail because the connector looks for Application Default Credentials.The tests run against the unshaded
HadoopCredentialsConfigurationfrom 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 realGoogleHadoopFileSystemor a GCS bucket. On Windows with JDK 17,GcsCredPropsTest,S3CredPropsTest,AzureCredPropsTest,CredPropsRoundTripTestand theidtests pass, and at the current head the fullhadoop/test(1528 tests) and the hadoop format checks pass. The Spark integration tests run in CI.