Repository navigation
feat(zonal): store content_type and metadata on Zonal and RCU writes - #1237
Yonghui-Lee wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Summary
gRPC writes to Zonal and RCU buckets drop
content_type,metadataandfixed_key_metadataand log "These parameters will be ignored." So the samepipe_filecall stores metadata on a Standard bucket but not on a Rapid bucket. Callers that rely on metadata, such as ADK'sFsspecArtifactService, had to patch it afterwards withsetxattrs.AsyncAppendableObjectWriter.from_blobsends the Blob as the new object's resource, and gcsfs already uses it forkms_key_name. This change uses the same path for content type and metadata.Changes
zb_hns_utils.init_aaowtakes aresource_blob. When it is set (orkms_key_nameis), the writer is opened withfrom_blob(generation=...). KMS is set on the same blob, andstorage_classis set for RCU writes.ExtendedGcsFileSystem._init_aaowbuilds that blob withparallel_upload._build_blobwhencontent_type(other than theapplication/octet-streamdefault),metadataorfixed_key_metadatais set. Writes without them still use the plain constructor._put_file,_pipe_file,simple_upload,initiate_uploadandZonalFilewrites pass the values through, and the "will be ignored" warnings are gone.consistencyis still ignored and still warns._put_fileguesses the content type from the file name, like the HTTP and parallel-upload paths.mode="create"keeps mapping togeneration=0, so a create-only write now carries metadata too.Dependency
from_blob(generation=...)andPreconditionscame 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 thereinit_aaowraisesNotImplementedErrorwhen 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-storageinpyproject.tomland 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
test_zb_hns_utils.py,test_zonal_unit.py,test_rcu_unit.pyandtest_zonal_file.py(mockedfrom_blob).test_zonal_unit,test_rcu_unit,test_zb_hns_utils,test_zonal,test_zonal_file,test_parallel_upload_unit: 1410 passed, 16 skipped.test_hns_unit::test_get_control_plane_client_endpointcases fail locally withMutualTLSChannelError, which this change doesn't touch.generationonfrom_blob) stored the content type and metadata on Rapid, and a second create-only write raisedFileExistsError.