Skip to content

feat(zonal): store content_type and metadata on Zonal and RCU writes - #1237

Draft
Yonghui-Lee wants to merge 1 commit into
fsspec:mainfrom
Yonghui-Lee:feat/rapid-write-metadata
Draft

Yonghui-Lee wants to merge 1 commit into
fsspec:mainfrom
Yonghui-Lee:feat/rapid-write-metadata

Conversation

@Yonghui-Lee

Copy link
Copy Markdown
Collaborator

Summary

gRPC writes to Zonal and RCU buckets drop content_type, metadata and fixed_key_metadata and log "These parameters will be ignored." So the same pipe_file call stores metadata on a Standard bucket but not on a Rapid bucket. Callers that rely on metadata, such as ADK's FsspecArtifactService, had to patch it afterwards with setxattrs.

AsyncAppendableObjectWriter.from_blob sends the Blob as the new object's resource, and gcsfs already uses it for kms_key_name. This change uses the same path for content type and metadata.

Changes

  • zb_hns_utils.init_aaow takes a resource_blob. When it is set (or kms_key_name is), the writer is opened with from_blob(generation=...). KMS is set on the same blob, and storage_class is set for RCU writes.
  • ExtendedGcsFileSystem._init_aaow builds that blob with parallel_upload._build_blob when content_type (other than the application/octet-stream default), metadata or fixed_key_metadata is set. Writes without them still use the plain constructor.
  • _put_file, _pipe_file, simple_upload, initiate_upload and ZonalFile writes pass the values through, and the "will be ignored" warnings are gone. consistency is still ignored and still warns. _put_file guesses the content type from the file name, like the HTTP and parallel-upload paths.
  • Appending to an existing generation can't change object metadata, so the blob is dropped there with a DEBUG log.
  • mode="create" keeps mapping to generation=0, so a create-only write now carries metadata too.

Dependency

from_blob(generation=...) and Preconditions came with googleapis/google-cloud-python#18641. That change was rolled back for the 3.17.2 patch release (#19186) and is being restored in googleapis/google-cloud-python#19271. Released 3.17.x doesn't have it, and there init_aaow raises NotImplementedError when metadata is set, the same way KMS does today.

Blocked on that SDK release. Before this is ready for review, raise the minimum google-cloud-storage in pyproject.toml and the requirements files to that release. The version isn't known yet, so this draft doesn't change it.

Related: googleapis/google-cloud-python#19324 closes the gRPC stream when the writer's open fails. Without it every Rapid write leaks a pending request task (the zonal redirect), which is independent of this change.

Testing

  • New and updated unit tests in test_zb_hns_utils.py, test_zonal_unit.py, test_rcu_unit.py and test_zonal_file.py (mocked from_blob).
  • test_zonal_unit, test_rcu_unit, test_zb_hns_utils, test_zonal, test_zonal_file, test_parallel_upload_unit: 1410 passed, 16 skipped.
  • Full suite against the emulator: 2921 passed. 3 test_hns_unit::test_get_control_plane_client_endpoint cases fail locally with MutualTLSChannelError, which this change doesn't touch.
  • A prototype of this change on real Rapid and Standard buckets (with an SDK patched to accept generation on from_blob) stored the content type and metadata on Rapid, and a second create-only write raised FileExistsError.

gRPC writes to Zonal and RCU buckets dropped content_type, metadata and
fixed_key_metadata with a warning. Send them as the new object's resource
through AsyncAppendableObjectWriter.from_blob, the same path kms_key_name
already uses. Appends to an existing generation keep the object's metadata.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enables support for setting 'content_type', 'metadata', and 'fixed_key_metadata' during appendable and gRPC uploads to Zonal and RCU buckets in GCS. These parameters are now passed down to the 'AsyncAppendableObjectWriter' via a 'resource_blob' when creating or overwriting objects, and are gracefully ignored with a debug log when appending to an existing generation. Additionally, the content type is now guessed from the local path when uploading files, and obsolete warnings regarding ignored parameters have been removed. Comprehensive unit tests have been added to verify this new behavior. There are no review comments, so I have no feedback to provide.

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.53%. Comparing base (020dd9c) to head (425818b).

Files with missing lines Patch % Lines
gcsfs/zb_hns_utils.py 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1237      +/-   ##
==========================================
- Coverage   95.55%   95.53%   -0.03%     
==========================================
  Files          25       25              
  Lines        5562     5573      +11     
==========================================
+ Hits         5315     5324       +9     
- Misses        247      249       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant