Repository navigation
[Hadoop] Keep the GCS conflict check, hierarchical namespace and implicit dir repair off for vended tokens - #2281
Conversation
7a360db to
7c40922
Compare
|
/review |
Reading or writing a table on gs:// through Unity Catalog failed on Spark 4.2 and 4.3 with 403 errors from Google. The vended token only covers the table's folder, and two checks of Google's connector look beyond it: - fs.gs.create.items.conflict.check.enable reads the folders above a table. GcsCredPropsBuilder meant to turn it off unless the user sets it, with conf.get(key, "false"). Hadoop 3.5 now ships this key as true in its built-in core-default.xml, so conf.get found that and left the check on. - fs.gs.hierarchical.namespace.folders.enable (on by default in newer connectors) reads the bucket's layout when writing files. Both are now false unless the user set them, telling a user value from Hadoop's built-in default by the source of the value. The Spark docs now use Google's connector jar (4.0.10) on every Spark version, since Hadoop 3.5's own hadoop-gcp module cannot take a vended token; with this connector, Spark 4.1 also no longer needs the vectored-read workaround. Co-authored-by: Isaac <[email protected]> Signed-off-by: Timothy Wang <[email protected]>
7c40922 to
26107cc
Compare
|
/review |
…a GCS prop tests Add the two fs.gs.* settings to the Spark 4.2.x GCS command, explain how to turn the checks back on, reword the engineSets javadoc, and cover core-site.xml values and the HNS key in GcsCredPropsTest. Co-authored-by: Isaac <[email protected]> Signed-off-by: Timothy Wang <[email protected]>
|
/review |
…n the docs Real-GCS runs on Spark 4.0 and 4.1 with connector 4.0.10 show both settings break access when on: the bucket-layout lookup (on by default in the connector) breaks non-Delta writes, the folder check breaks everything. Add the bucket-layout setting to the 4.0.x and 4.1.x commands and describe both defaults in the note. Co-authored-by: Isaac <[email protected]> Signed-off-by: Timothy Wang <[email protected]>
|
/review |
1 similar comment
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Posting as a comment. Fixed since the last head: the 4.2.x example now sets both fs.gs settings, and the note names the connector's own HNS default and the Spark rows it applies to.
Still open at ba3f5fb:
- The constructor comment in
GcsCredPropsBuildersays the HNS lookup runs on writes (inline). - The docs note claims about writes and access need a named operation, or removal (inline).
- Test fixture and
core-site.xmlcoverage inGcsCredPropsTest(inline). - Two nits on the shared base class (inline).
- Description: please say that folder delete and rename on HNS buckets lose the connector's native folder path until users opt back in, and mention the
engineSetsmove intoCredPropsBuilder(a pure move for S3).
| // more than the table's own path, which a UC-vended downscoped token (scoped to a table's path | ||
| // prefix) is not allowed to do, so the call returns 403: | ||
| // - the conflict check stats every ancestor directory on file creation; | ||
| // - the hierarchical namespace lookup reads the bucket's layout when writing files. |
There was a problem hiding this comment.
[AI Assisted] The bullet says the hierarchical namespace lookup reads the bucket's layout when writing files. At gcsio v4.0.10 with the default settings, the lookup runs only from folder delete (gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageFileSystemImpl.java line 351) and directory rename (line 795). isHnsOptimized (line 1317) returns early unless fs.gs.hierarchical.namespace.folders.optimization.enable is true, which defaults to false, so mkdirs and create do not reach the lookup. Suggested wording: 'the hierarchical namespace lookup reads the bucket's layout when deleting or renaming a folder.'
There was a problem hiding this comment.
Agreed, and I checked it. With only the HNS setting forced on, a parquet write on Spark 4.1 fails with a 403 at GoogleCloudStorageFileSystemImpl.delete (line 351), reached from FileOutputCommitter.abortTask in the parquet commit. Delta writes pass. Reworded the comment to say the lookup runs when a folder is deleted or renamed. I only saw delete in my runs, not rename.
| Unity Catalog vends cannot do, so access fails: | ||
|
|
||
| - `fs.gs.hierarchical.namespace.folders.enable` reads the bucket's layout. The connector turns it on itself, on every | ||
| Spark version, and it breaks writes to non-Delta tables. |
There was a problem hiding this comment.
[AI Assisted] This note says the HNS setting 'breaks writes to non-Delta tables' and the conflict check 'breaks all access'. The connector source does not show either one. At v4.0.10 the HNS flag gates the bucket-layout lookup only in folder delete (GoogleCloudStorageFileSystemImpl.java line 351) and directory rename (line 795). Please name the operation that fails for each setting, or drop the claim.
There was a problem hiding this comment.
Good catch. Reworded. HNS: reads the bucket layout on folder delete or rename, so parquet tables fail (their commit deletes folders) and Delta tables don't. Conflict check: with it forced on, creating _delta_log fails on Error getting 'gs://.../data' object, because it stats the folders above the table, so creating a table or writing to it fails. I haven't tested reads alone, so I dropped "all access".
| + HNS_FOLDERS_KEY | ||
| + "</name><value>true</value></property>" | ||
| + "</configuration>"; | ||
| conf.addResource(new ByteArrayInputStream(defaults.getBytes(UTF_8)), "core-default.xml"); |
There was a problem hiding this comment.
[AI Assisted] This fixture puts fs.gs.hierarchical.namespace.folders.enable at true in core-default.xml, and the assertion below it checks that value. Hadoop 3.5.0's core-default.xml has no HNS key. The true default comes from the connector (gcs/CONFIGURATION.md at v4.0.10). Consider removing that entry from the fixture, or saying in a comment where the true comes from.
There was a problem hiding this comment.
You're right. Hadoop 3.5.0's core-default.xml has the conflict key but no HNS key; the true comes from the connector. The fixture now only has the conflict key, asserts the HNS key is absent from the Hadoop conf, and checks both keys come out false. The test javadoc says where the HNS true comes from.
| conf.addResource(new ByteArrayInputStream(defaults.getBytes(UTF_8)), "core-default.xml"); | ||
| conf.addResource(new ByteArrayInputStream(site.getBytes(UTF_8)), "core-site.xml"); | ||
|
|
||
| assertThat(tableProps(conf)).containsEntry(CONFLICT_CHECK_KEY, "true"); |
There was a problem hiding this comment.
[AI Assisted] This case uses the same true in both resources and asserts only the conflict key, so the HNS key is not covered on the core-site.xml path. Suggested: set core-site.xml to false for one of the two keys, and assert both keys.
There was a problem hiding this comment.
Done: the case now sets both keys to true in core-site.xml on top of the default and asserts both. I didn't use false for one key, because that is also the forced value, so it couldn't tell "respected" from "overridden".
| * core-default.xml}, including {@code true} for the conflict check, so reading the key with a | ||
| * fallback of {@code false} would find that default and keep the check on. | ||
| */ | ||
| protected void setOffUnlessEngineSets(String key) { |
There was a problem hiding this comment.
[AI Assisted] setOffUnlessEngineSets is GCS-specific policy in the shared base class, and GcsCredPropsBuilder is its only caller. Consider making it private in GcsCredPropsBuilder, and keeping engineSets here since S3 also uses it. If it stays here, the javadoc could describe only the contract: sets key to false unless the engine's configuration sets it.
There was a problem hiding this comment.
Moved to a private method in GcsCredPropsBuilder with a one-line javadoc. engineSets stays in the base class for S3.
| return false; | ||
| } | ||
| String[] sources = hadoopConf().getPropertySources(key); | ||
| return sources == null || !Arrays.stream(sources).allMatch("core-default.xml"::equals); |
There was a problem hiding this comment.
[AI Assisted] This branch treats a key with no recorded source as engine-set, so a value Hadoop does not attribute is kept rather than replaced. getPropertySources returns null when Hadoop records no source for the key. A one-line comment saying so would make the choice visible.
There was a problem hiding this comment.
Added a comment: Hadoop records no source for a key it did not load from a resource, so that counts as set.
Real-GCS runs show INSERT OVERWRITE on a parquet table fails on Spark 4.0 to 4.3: deleting the partition folder makes Google's connector recreate the parent folder, which a table-scoped token cannot touch. Turn fs.gs.implicit.dir.repair.enable off the same way as the other two GCS checks, and add it to the docs commands and note. Co-authored-by: Isaac <[email protected]> Signed-off-by: Timothy Wang <[email protected]>
|
/review |
…S policy in GcsCredPropsBuilder, add streaming checkpoint note Say which connector operation each setting breaks (folder delete or rename for the hierarchical namespace lookup, parent folder stats on create for the conflict check), move setOffUnlessEngineSets into GcsCredPropsBuilder, and cover core-site.xml values for both keys. Add a docs note that a streaming checkpoint location gets no Unity Catalog credentials. Co-authored-by: Isaac <[email protected]> Signed-off-by: Timothy Wang <[email protected]>
|
/review |
|
Thanks, all inline points are addressed in the latest commit. Description updated: folder delete and rename on hierarchical-namespace buckets lose the connector's native folder path until users opt back in, and |
…omment, note the HNS tradeoff Co-authored-by: Isaac <[email protected]> Signed-off-by: Timothy Wang <[email protected]>
|
/review |
…ts rule once Co-authored-by: Isaac <[email protected]> Signed-off-by: Timothy Wang <[email protected]>
|
/review |
1 similar comment
|
/review |
…pplies to renewing credentials Co-authored-by: Isaac <[email protected]> Signed-off-by: Timothy Wang <[email protected]>
|
Addressed the review nits that change behavior or test coverage: the repair key is asserted in the tests, each key is tested independently, the I'm leaving the remaining nits as they are (the |
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Posting as a comment at e3ad8b6. Earlier items are addressed: the constructor wording for HNS and the conflict check, the operations named in the docs note, the fixture, the core-site case, the helper placement, the null-source comment, and the description. The streaming auth-type sentence holds for the default renewing credentials.
Still open: the implicit-repair example (inline, in the constructor comment and the docs note).
Optional, inline: the pre-0.8.0 note on the Hadoop 3.5 default, and the engineSets Javadoc.
Optional, title: the title says 'on Hadoop 3.5', but only the conflict check is Hadoop 3.5 specific. The other two keys are off on every Spark version. A title such as '[Hadoop] Keep the GCS conflict check, hierarchical namespace and implicit dir repair off for vended tokens' would match the change.
| // - the implicit directory repair recreates the parent folder after a directory delete, such | ||
| // as the partition delete of INSERT OVERWRITE on a parquet table; the connector turns it on |
There was a problem hiding this comment.
[AI Assisted] The implicit directory repair bullet names the wrong failing call. In folder delete, the parent lookup starts before the delete (gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageFileSystemImpl.java lines 342-344). The repair awaits that lookup with getFromFuture (line 932), so an IOException there ends the delete. The placeholder write (createEmptyObject, line 946) catches IOException and only logs a warning (line 950), so the write alone cannot fail the delete. Please name the parent lookup in folder delete as the failing call, or show and cite the INSERT OVERWRITE path that fails, or drop the INSERT OVERWRITE example.
There was a problem hiding this comment.
You're right, the failing call is the parent lookup in folder delete, not the placeholder write. The INSERT OVERWRITE trace is InsertIntoHadoopFsRelationCommand.deleteMatchingPartitions → GoogleHadoopFileSystem.delete → GoogleCloudStorageFileSystemImpl.delete (397) → repairImplicitDirectory (932) → getFromFuture, failing with "Error accessing gs://.../data/". Reworded to "looks up the parent folder" in the comment, docs and description. I kept the INSERT OVERWRITE example because that is the path that fails, and turning the setting off fixes it.
| - `fs.gs.create.items.conflict.check.enable` reads every folder above a new file or folder. Hadoop 3.5 (Spark 4.2.x) | ||
| turns it on. Creating a table or writing to it fails. | ||
| - `fs.gs.implicit.dir.repair.enable` recreates the parent folder after a folder is deleted. The connector turns it on | ||
| itself, and it breaks `INSERT OVERWRITE` on parquet tables. |
There was a problem hiding this comment.
[AI Assisted] Same point as the comment on GcsCredPropsBuilder.java: the failing call is the parent lookup in folder delete, not the placeholder write. Please name that call, cite the INSERT OVERWRITE path, or drop the example.
There was a problem hiding this comment.
Same fix as the constructor comment: the note now says the setting looks up the parent folder after a folder is deleted, and the INSERT OVERWRITE example stays since that path fails in my runs.
|
|
||
| From 0.8.0 Unity Catalog turns all three off itself, so the `--conf` lines for them in the commands above can be | ||
| dropped. If your credentials are broad enough for those calls (for example on a hierarchical-namespace bucket), set | ||
| one to `true` in your Spark config and the connector keeps your value. With the hierarchical namespace setting off, |
There was a problem hiding this comment.
[AI Assisted] Optional: Hadoop 3.5's built-in true for the conflict check does not count as an opt-in, because the engine's configuration does not set it. Anyone who relied on that default must now set the key explicitly. Saying so here would help them find it.
There was a problem hiding this comment.
Added, thanks.
|
|
||
| /** | ||
| * Whether the engine's configuration sets {@code key} itself: a value counts as the engine's own | ||
| * unless every recorded source is {@code core-default.xml}. |
There was a problem hiding this comment.
[AI Assisted] Optional: the Javadoc states the rule but no longer names the Hadoop defaults it is meant to skip. Naming them here, for example S3A's default provider list and Hadoop 3.5's GCS conflict-check default, would explain why core-default.xml is special.
There was a problem hiding this comment.
Added both examples back.
…air call; document the Hadoop 3.5 default Co-authored-by: Isaac <[email protected]> Signed-off-by: Timothy Wang <[email protected]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Approving at af36b5e. The earlier items are addressed: the implicit-repair wording (the parent lookup in folder delete, which matches the connector source), the Hadoop 3.5 conflict-check opt-in sentence, the engineSets Javadoc, and the title.
Follow-up, not blocking: the PR description says the conflict-check setting 'breaks everything'. The docs now say that creating a table or writing to it fails, and reads were not tested. Please align the description with the docs, or drop 'breaks everything'.
Nits, inline: one long line in the pre-0.8.0 note, and no test for the sources == null branch of engineSets.
| From 0.8.0 Unity Catalog turns all three off itself, so the `--conf` lines for them in the commands above can be | ||
| dropped. If your credentials are broad enough for those calls (for example on a hierarchical-namespace bucket), set | ||
| one to `true` in your Spark config and the connector keeps your value. Hadoop 3.5's own `true` for the conflict check | ||
| does not count as setting it, so if you relied on that default, set the key to `true` yourself. With the hierarchical namespace setting off, |
There was a problem hiding this comment.
[AI Assisted] Nit: this line is 144 characters, much longer than the lines around it. Splitting the Hadoop 3.5 caveat and the hierarchical namespace caveat into separate lines would match the note's wrapping.
| } | ||
| // No recorded source means we cannot show the value came from defaults, so respect it. | ||
| String[] sources = hadoopConf().getPropertySources(key); | ||
| return sources == null || !Arrays.stream(sources).allMatch("core-default.xml"::equals); |
There was a problem hiding this comment.
[AI Assisted] Nit: no test covers this sources == null branch. A test with a Configuration whose getPropertySources returns null, asserting that the HNS key stays true, would cover it. Optional.
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedDescription of changes
Fixes #2278: reading or writing a table on
gs://through Unity Catalog failed on Spark 4.2 and 4.3 with403errors from Google.Why it failed. The token Unity Catalog vends only covers the table's own folder. Google's GCS connector has three settings that make it touch things outside that folder:
fs.gs.create.items.conflict.check.enablereads every folder above a new file or folder, so creating a table or writing to it fails. Unity Catalog already tried to turn it off, but Hadoop 3.5 started shipping it as "on" in its own defaults, and our code took that default for the user's choice.fs.gs.hierarchical.namespace.folders.enablereads the bucket's layout when a folder is deleted or renamed. The connector turns it on itself, on every Spark version. Parquet tables fail because their commit deletes folders; Delta tables do not.fs.gs.implicit.dir.repair.enablelooks up the parent folder after a folder is deleted, for example byINSERT OVERWRITEon a parquet table. The connector turns it on itself, on every Spark version.The fix
true.engineSetsmoved from the S3 builder intoCredPropsBuilder(moved with a generalized comment; S3 behavior is unchanged). The GCS-onlysetOffUnlessEngineSetsstays inGcsCredPropsBuilder.Testing
INSERT OVERWRITEon parquet tables.Not covered. Reading a bare
gs://path with the DataFrame API (spark.read.parquet("gs://...")) doesn't use Unity Catalog credentials on any version. This PR doesn't change that.