Skip to content

[Bug]: [yaml-template] Unconditional boto3/azure-storage-blob requirements_file injection hangs air-gapped --no-use-public-ips jobs #4565

Open

Description

@jk-shah

What happened?

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

  1. 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
  2. Only inject boto3 / azure-storage-blob when the YAML spec actually references s3:// or azfs:// URIs.

Activity

  1. ashokballolli commented on Nov 17, 2026

    @ashokballolli

    Hi, I would like to work on this.

    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?

  2. ashokballolli commented on Nov 17, 2026

    @ashokballolli

    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.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?

  3. kennknowles commented on Nov 17, 2026

    @kennknowles
    Contributor

    @chamikaramj knows the answer better than I do.

  4. chamikaramj commented on Nov 17, 2026

    @chamikaramj
    Contributor

    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.

  5. ashokballolli commented on Nov 17, 2026

    @ashokballolli

    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.

  6. chamikaramj commented on Nov 17, 2026

    @chamikaramj
    Contributor

    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.

  7. ashokballolli commented on Nov 17, 2026

    @ashokballolli

    Sure, I will run it end to end on Dataflow with private IPs first and share the results before sending a PR.

  8. ashokballolli commented on Nov 17, 2026

    @ashokballolli

    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.

    Network setup
    1-network-setup

    All runs
    2-all-runs

    Current template, private IPs
    3-current-template-private-ips

    My change, private IPs
    4-with-change-private-ips

    My change, public IPs
    5-with-change-public-ips

    If this looks fine, I will open the PR.

  9. chamikaramj commented on Nov 19, 2026

    @chamikaramj
    Contributor

    Looks good to me. Thanks!

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions