You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When launching a Beam YAML Flex Template job using the stock gcr.io/dataflow-templates/yaml-template image in an enterprise VPC with --no-use-public-ips (ipConfiguration=WORKER_IP_PRIVATE) and no outbound internet / Cloud NAT to pypi.org, the launcher container hangs for ~10 minutes retrying pip download against pypi.org (Network is unreachable) and fails—even when the YAML pipeline only reads/writes GCS or BigQuery (gs://, bigquery://) and needs zero extra PyPI packages.
Cause
In yaml-template (template/main.py), whenever --requirements_file is not passed on argv, the entrypoint writes a temporary requirements.txt containing boto3, botocore, and azure-storage-blob and appends --requirements_file=<tmp>. Apache Beam's stager.py then invokes pip download -r <tmp> over the network against pypi.org during job staging.
(Workaround discovered: injecting options: {requirements_file: null} into yamlDefinition overrides PipelineOptions.requirements_file back to None inside apache_beam.yaml.main._build_pipeline_options.)
Suggested Fix
Pre-install boto3, botocore, and azure-storage-blob inside the yaml-template container image (or stage pre-downloaded wheels in a local wheelhouse directory passed via --find-links / --no-index), or
Only inject boto3 / azure-storage-blob when the YAML spec actually references s3:// or azfs:// URIs.
I think option 2 fits well with how the template already handles ML dependencies (ml_dependencies.py reads the YAML and adds packages only when needed). The plan is:
Add boto3 / botocore only when the pipeline or its arguments use s3://
Add azure-storage-blob / azure-core / azure-identity only when they use azfs://
Keep the job builder package (job_builder_util_transforms) as it is
Add unit tests for both cases
Does this approach look okay, or would you prefer to pre-install these packages in the image instead?
Before starting, I checked one more thing. Making only boto3/azure conditional will not fully fix the air-gapped case. The default list also has the job builder package (job_builder_util_transforms-0.2.2.tar.gz from storage.googleapis.com). It is a source package built with poetry, so pip download needs poetry-core from pypi.org to prepare it. I tried pip download --no-deps on that URL with the index pointed to an unreachable host, and it failed with No matching distribution found for poetry-core.
So I am planning to make the job builder package conditional too. It only has ReadFromDeltaLake and CopyFilesToGCS, so I would add it only when the pipeline refers to these transforms (by class name, or by module name read_from_delta_lake / copy_files_to_gcs). Then a pipeline that only uses GCS/BigQuery gets no requirements file at all, and pip download is not run.
If the YAML cannot be loaded, it will keep the current behaviour and add all the default packages, so nothing changes for those cases.
Is checking for these names the right way to find job builder pipelines, or does Job Builder mark its pipelines in some other way?
I think a better approach might be to detect whether the pipeline needs VPC and not use the custom requirements file at all in that case. This means that VPC pipelines can only use pipelines that use dependencies available in the container image but that is expected.
Thank you, that really helps. I will go with that.
Plan:
Read the pipeline options the same way Beam YAML does (command line args and the options section of the YAML) and check use_public_ips.
If it is False, do not add the requirements file at all (including the ML dependencies), and log a message saying the default dependencies were skipped because the job uses private IPs.
Everything else stays as it is now.
I am taking "no public IPs" as the signal, since a job on a custom subnetwork with public IPs can still reach PyPI.
One question: when the template is launched with private IPs (ipConfiguration=WORKER_IP_PRIVATE / --disable-public-ips), does the Flex template launcher pass --no_use_public_ips to the container? I could not test this myself, so I want to make sure the check sees it.
Ran the end to end test on Dataflow as you suggested (us-central1). I used the default subnet with Private Google Access on and no Cloud NAT, so the machines with private IPs had no internet access.
What I saw:
Current template with public IPs: job worked fine.
Current template with --disable-public-ips: the launcher got stuck at pip download boto3 and the job failed with Timeout in polling result file.
Same image with only my changed main.py and --disable-public-ips: the launcher passed --no_use_public_ips to main.py, the requirements file was not added and the job succeeded.
Same changed image with public IPs: pip download ran like before and the job succeeded.
Activity
ashokballolli commentedon Nov 17, 2026
Hi, I would like to work on this.
I think option 2 fits well with how the template already handles ML dependencies (
ml_dependencies.pyreads the YAML and adds packages only when needed). The plan is:boto3/botocoreonly when the pipeline or its arguments uses3://azure-storage-blob/azure-core/azure-identityonly when they useazfs://job_builder_util_transforms) as it isDoes this approach look okay, or would you prefer to pre-install these packages in the image instead?
ashokballolli commentedon Nov 17, 2026
Thanks for assigning this to me.
Before starting, I checked one more thing. Making only boto3/azure conditional will not fully fix the air-gapped case. The default list also has the job builder package (
job_builder_util_transforms-0.2.2.tar.gzfrom storage.googleapis.com). It is a source package built with poetry, sopip downloadneedspoetry-corefrom pypi.org to prepare it. I triedpip download --no-depson that URL with the index pointed to an unreachable host, and it failed withNo matching distribution found for poetry-core.So I am planning to make the job builder package conditional too. It only has
ReadFromDeltaLakeandCopyFilesToGCS, so I would add it only when the pipeline refers to these transforms (by class name, or by module nameread_from_delta_lake/copy_files_to_gcs). Then a pipeline that only uses GCS/BigQuery gets no requirements file at all, andpip downloadis not run.If the YAML cannot be loaded, it will keep the current behaviour and add all the default packages, so nothing changes for those cases.
Is checking for these names the right way to find job builder pipelines, or does Job Builder mark its pipelines in some other way?
kennknowles commentedon Nov 17, 2026
@chamikaramj knows the answer better than I do.
chamikaramj commentedon Nov 17, 2026
I think a better approach might be to detect whether the pipeline needs VPC and not use the custom requirements file at all in that case. This means that VPC pipelines can only use pipelines that use dependencies available in the container image but that is expected.
ashokballolli commentedon Nov 17, 2026
Thank you, that really helps. I will go with that.
Plan:
optionssection of the YAML) and checkuse_public_ips.False, do not add the requirements file at all (including the ML dependencies), and log a message saying the default dependencies were skipped because the job uses private IPs.I am taking "no public IPs" as the signal, since a job on a custom subnetwork with public IPs can still reach PyPI.
One question: when the template is launched with private IPs (
ipConfiguration=WORKER_IP_PRIVATE/--disable-public-ips), does the Flex template launcher pass--no_use_public_ipsto the container? I could not test this myself, so I want to make sure the check sees it.chamikaramj commentedon Nov 17, 2026
Please test it by running a pipeline end-to-end before sending a fix.
Please make sure that all fixes a verified by a human not just agent generated.
ashokballolli commentedon Nov 17, 2026
Sure, I will run it end to end on Dataflow with private IPs first and share the results before sending a PR.
ashokballolli commentedon Nov 17, 2026
Ran the end to end test on Dataflow as you suggested (us-central1). I used the
defaultsubnet with Private Google Access on and no Cloud NAT, so the machines with private IPs had no internet access.What I saw:
--disable-public-ips: the launcher got stuck atpip download boto3and the job failed withTimeout in polling result file.main.pyand--disable-public-ips: the launcher passed--no_use_public_ipstomain.py, the requirements file was not added and the job succeeded.pip downloadran like before and the job succeeded.Network setup

All runs

Current template, private IPs

My change, private IPs

My change, public IPs

If this looks fine, I will open the PR.
chamikaramj commentedon Nov 19, 2026
Looks good to me. Thanks!