Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions lib/galaxy/jobs/runners/gcp_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,27 @@ def _create_batch_job_spec(self, job_wrapper, ajs, params):
# Configure network for NFS access (required when using NFS volumes)
if parsed_volumes:
network_interface = batch_v1.AllocationPolicy.NetworkInterface()
network_interface.network = f"global/networks/{params.get('network', 'default')}"
network_interface.subnetwork = f"regions/{params['region']}/subnetworks/{params.get('subnet', 'default')}"
# Qualify bare names with the project so Batch resolves them in project_id's
# VPC, not the (possibly different, e.g. a Terra pet) project the Batch VMs are
# provisioned in -- a relative "global/networks/<name>" resolves against the
# latter and 404s. A value that is already a full/relative path is passed through.
project_id = params["project_id"]
network = params.get("network", "default")
subnet = params.get("subnet", "default")
network_interface.network = (
network if "/" in network else f"projects/{project_id}/global/networks/{network}"
)
network_interface.subnetwork = (
subnet if "/" in subnet else f"projects/{project_id}/regions/{params['region']}/subnetworks/{subnet}"
)

network_policy = batch_v1.AllocationPolicy.NetworkPolicy()
network_policy.network_interfaces = [network_interface]
allocation_policy.network = network_policy
log.debug(
"Configured network for NFS access: %s/%s for job %s",
params.get("network", "default"),
params.get("subnet", "default"),
"Configured network for NFS access: %s / %s for job %s",
network_interface.network,
network_interface.subnetwork,
job_wrapper.get_id_tag(),
)

Expand Down
Loading