Dynamic VM sizing, resource env injection, and job lifecycle controls for GCP Batch#473
Open
ksuderman wants to merge 6 commits into
Open
Dynamic VM sizing, resource env injection, and job lifecycle controls for GCP Batch#473ksuderman wants to merge 6 commits into
ksuderman wants to merge 6 commits into
Conversation
Rename gcp_galaxy_instance_id to gcp_job_id_prefix with fallback chain: job_id_prefix > galaxy_instance_id > "pulsar". This allows distinguishing Pulsar batch jobs from direct batch jobs in the GCP console. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 3 — Dynamic VM sizing, resource env injection, and job lifecycle controls for GCP Batch
Part of #465.
Summary
Makes the GCP Batch runner size VMs from per-tool resource requests, gives tools the
full VM resources, and adds operational controls for job naming and cleanup. Before
this PR every job used a fixed
machine_type, tools ran single-threaded regardless ofthe VM, job names could collide, N2/N2D local-SSD counts were rejected, and jobs were
always deleted on cancel (losing Cloud Logging for debugging).
What's included
1. Dynamic VM sizing from
cores/mem.Adds
coresandmemfields toGcpJobParams. When either is set,parse_gcp_job_params()computes an appropriate N2 machine type via a newcompute_machine_type()helper ingcp_util.py(withconvert_cpu_to_milli()andconvert_memory_to_mib()), choosing betweenhighcpu/standard/highmemvariants.These helpers are intentionally Galaxy-free so Galaxy's direct
GoogleCloudBatchJobRunnercan import them from Pulsar in a follow-up and share oneimplementation.
2. Inject
GALAXY_SLOTS/GALAXY_MEMORY_MBand set the container compute resource.On a Batch VM there is no scheduler environment, so
$GALAXY_SLOTSfell through to1and tools ran single-threaded. When
cores/memare set, these env vars are injectedinto the task environment and
task.compute_resourceis set so the container gets thefull VM instead of Batch's default 2 vCPU / 2 GB.
3. Validate local-SSD count for N2/N2D machine types.
Replaces a bare
assert size_gb % 375 == 0with_validate_ssd_size(), which rounds upto the nearest 375 GB and adds one more SSD for N2/N2D when the count is odd (these
types require an even count), logging the adjustment instead of crashing.
4. Collision-free job names with a configurable prefix.
Replaces the K8s-style name generator with
{prefix}-{job_id}-{unix_timestamp}andcaches it so submit/poll/delete agree. Renames the internal helper
gcp_galaxy_instance_id→gcp_job_id_prefix, resolving the prefix asjob_id_prefix>galaxy_instance_id>"pulsar"so jobs from different Galaxyinstances sharing a project are distinguishable.
5. Optional job deletion and AMQP
kill().Both client
kill()paths now honor adelete_batch_jobdestination param (defaulttrue); setfalseto retain jobs and their Cloud Logging for debugging. Adds thepreviously missing
kill()toGcpMessageCoexecutionJobClientand wraps deletion intry/except so a failed delete doesn't cascade.
Files changed
pulsar/client/client.pypulsar/client/container_job_config.pypulsar/managers/util/gcp_util.pyTesting
Verified VMs are sized from TPV
cores/mem, tools run multi-threaded with theinjected
GALAXY_SLOTS, N2 jobs provision with corrected SSD counts, job names nolonger collide, and jobs are retained when
delete_batch_job: false.flake8clean.Notes
gcp_galaxy_instance_idhelper togcp_job_id_prefix; if PR 1has merged first this PR may need a trivial rebase. Recommended to merge last of the
three.
galaxy/jobs/runners/util/gcp_batch/helpers.pyto re-export the sizing helpers frompulsar.managers.util.gcp_utilso both runners share one implementation.