Skip to content
Merged
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
24 changes: 22 additions & 2 deletions pulsar/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,13 +1120,33 @@ def _launch_containers(
assert pulsar_finish_container is None
gcp_job_params = self._gcp_job_params
job = gcp_job_template(gcp_job_params)
runnable = container_command_to_gcp_runnable("pulsar-container", pulsar_submit_container)
job.task_groups[0].task_spec.runnables.append(runnable)

# Parse docker_extra_volumes (comma-separated Docker -v style strings)
# into a list for GCP Batch Runnable.Container.volumes
extra_volumes = []
raw = self.destination_params.get("docker_extra_volumes", "")
if raw:
extra_volumes = [v.strip() for v in raw.split(",") if v.strip()]

# Order matters: GCP Batch runs runnables sequentially. A background
# runnable starts and immediately yields to the next runnable. We need:
# 1. Tool (background) — starts polling for command_line file
# 2. Sidecar (foreground) — stages inputs, writes command_line, polls
# for return_code, collects outputs, sends AMQP callback
# The sidecar must be foreground so it survives after the tool finishes
# (GCP Batch kills background runnables when all foreground ones exit).
if tool_container:
tool_runnable = container_command_to_gcp_runnable("tool-container", tool_container)
tool_runnable.background = True
if extra_volumes:
tool_runnable.container.volumes = extra_volumes
job.task_groups[0].task_spec.runnables.append(tool_runnable)

runnable = container_command_to_gcp_runnable("pulsar-container", pulsar_submit_container)
if extra_volumes:
runnable.container.volumes = extra_volumes
job.task_groups[0].task_spec.runnables.append(runnable)

job_name = self._job_name
create_request = gcp_job_request(gcp_job_params, job, job_name)
client = gcp_client(gcp_job_params.credentials_file)
Expand Down