Repository navigation
Support Environment Sensitive Staging - #40699
tarun-google wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR fixes artifact staging for Dataflow jobs using prebuilt SDK container images (--prebuild_sdk_container_engine) by decoupling pipeline environment artifact dependencies from the job-level staged resources in apiclient.py, and introduces a fallback in boot.go to copy pre-staged artifacts from /opt/apache/beam/artifacts when no artifacts are provided via the Provision API.
🔍 General Feedback
- The separation of
dependencies(for pipeline proto environments) andresources(for Dataflow job staging) inapiclient.pycleanly resolves the regression whereStager.create_job_resourceswas skipped during job submission. - However, the fallback in
boot.gohas a couple of edge cases regardingsubmission_environment_dependencies.txt(which is always staged byapiclient.pyeven with prebuilt containers) and potential filename collisions across multiple prebuilt image layers.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
💬 Inline Findings
sdks/python/container/boot.go(line 270): 🟠 High:len(info.GetDependencies()) == 0will evaluate tofalseon Dataflow even when--prebuild_sdk_container_engineis used, preventing this fallback from ever executing on Dataflow. Inapiclient.py,_stage_resourcescallsStager.create_job_resourceswith the defaultlog_submission_env_dependencies=True, which stagessubmission_environment_dependencies.txtto GCS. Dataflow's runner harness populatesProvisionInfo.dependenciesfrom the job's GCSpackageslist (not from the pipeline proto'sEnvironment.dependencies), meaninginfo.GetDependencies()will containsubmission_environment_dependencies.txt(length 1) rather than being empty.
Additionally, even if /opt/apache/beam/artifacts is copied to dir, installSetupPackages only iterates over the files slice populated from artifacts (lines 296-304). Any workflow.tar.gz or PICKLED_MAIN_SESSION copied from /opt/apache/beam/artifacts won't be in files and thus won't be processed by installSetupPackages (though PICKLED_MAIN_SESSION in dir is still picked up by sdk_worker_main.py). Consider checking if /opt/apache/beam/artifacts exists and merging/copying any local artifacts not already present in dir.
-
sdks/python/container/boot.go(line 484): 🟡 Medium:copyDirwalkssrcrecursively (which includes subdirectories like/opt/apache/beam/artifacts/<hash>/...created byboot --setup_onlyduring the image build), but flattens all files into the top-leveldstdirectory usingfilepath.Base(path). Becauseboot --setup_onlyalready copies artifacts from/opt/apache/beam/artifacts/<name>into/opt/apache/beam/artifacts/<hash>/<name>, every artifact exists at least twice under/opt/apache/beam/artifacts. If a user builds a multi-layered prebuilt image, older subdirectories could overwrite newer top-level files depending on lexical walk order, or if any subdirectory exists,os.Open(path)followed byio.Copyon a directory entry will fail or produce unexpected behavior ifinfo.IsDir()wasn't skipped (thoughinfo.IsDir()is skipped, nested files in subdirectories will still collide onfilepath.Base(path)). Consider usingos.ReadDir(src)instead offilepath.Walkto only copy regular files in the top-level/opt/apache/beam/artifactsdirectory (and skipartifacts_info.json). -
sdks/python/container/boot.go(line 500): 🟢 Low:defer out.Close()ignores any write/flush errors that occur when closing the destination file, and keepingdeferinside thefilepath.Walkcallback holds all file descriptors open untilcopyDirreturns. Closeinandoutexplicitly per iteration and check the error fromout.Close().
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40699 +/- ##
===========================================
- Coverage 80.04% 56.44% -23.61%
===========================================
Files 490 871 +381
Lines 82916 154214 +71298
===========================================
+ Hits 66373 87048 +20675
- Misses 16543 65307 +48764
- Partials 0 1859 +1859
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Assigning reviewers: R: @claudevdm for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
claudevdm
left a comment
There was a problem hiding this comment.
Can you trigger post commits?
|
R: @tvalentyn can you PTAL too since this has a large blast radius. |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
|
Run Python PostCommit |
DOC: https://docs.google.com/document/d/1gNfjbIYNzbv15-RjCj0ad4MHenVPoSjUEcH0Ok3iNyU/edit?usp=sharing
Tested dependencies are downloaded to separate directories by sdk container

requirements.txt are appended with sha-256 to avoid replacing
