Skip to content

Commit

Permalink
Fix deployment of multiple Batch jobs
Browse files Browse the repository at this point in the history
Two issues:

1. The submit_script_output_path did not depend on the
ID of the job to be submitted, so one job's submit script could
overwrite a different job's submit script.

2. The submit_job resource did not explicitly depend on the submit_script
resource and as a result would sometimes execute before the script
was written (causing submisison to fail with a file-not-found error).
  • Loading branch information
aaronegolden committed May 1, 2024
1 parent 07ccd70 commit 519aec5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/scheduler/batch-job-template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ locals {
submit_job_id = local.submit_job_id
}
)
submit_script_output_path = "${path.root}/submit-job.sh"
submit_script_output_path = "${path.root}/submit-${local.submit_job_id}.sh"

subnetwork_name = var.subnetwork != null ? var.subnetwork.name : "default"
subnetwork_project = var.subnetwork != null ? var.subnetwork.project : var.project_id
Expand Down Expand Up @@ -117,7 +117,7 @@ resource "local_file" "submit_script" {
}

resource "null_resource" "submit_job" {
depends_on = [local_file.job_template]
depends_on = [local_file.job_template, local_file.submit_script]
count = var.submit ? 1 : 0

# A new deployment should always submit a new job. Old finished jobs aren't persistent parts of
Expand Down

0 comments on commit 519aec5

Please sign in to comment.