We’re new to nomad and have a job file that uses an input variable to specify the container image to use like this:
variable "project_image" {
type = string
description = "The image to use for the project"
}
job "job" {
group "group"
task "task" {
driver = "podman"
config {
image = var.project_image
}
}
}
}
And trigger deployments in GitHub Actions when a new image version has been built successfully.
Today, we had a case where two deployments were triggered in short succession with different image versions.
We saw two different plans being created, with the correct changes detected:
Tue, 25 Feb 2025 15:56:33 GMT +/- Job: "job"
Tue, 25 Feb 2025 15:56:33 GMT +/- Task Group: "group" (1 create/destroy update, 1 ignore)
Tue, 25 Feb 2025 15:56:33 GMT +/- Task: "task" (forces create/destroy update)
Tue, 25 Feb 2025 15:56:33 GMT +/- Config {
Tue, 25 Feb 2025 15:56:33 GMT +/- image: "ghcr.io/demvsystems/stuff@sha256:bd3e5db2e4ffa9dca197bc7b94ad496bd50336219586160c09164723b131308a" => "ghcr.io/demvsystems/stuff@sha256:d47126837187957643d6de9219b83948f5be258a0082ab9b509ff232bb93cde7"
Tue, 25 Feb 2025 15:56:33 GMT }
Tue, 25 Feb 2025 15:56:33 GMT
Tue, 25 Feb 2025 15:56:33 GMT Scheduler dry-run:
Tue, 25 Feb 2025 15:56:33 GMT - All tasks successfully allocated.
Tue, 25 Feb 2025 15:56:33 GMT
Tue, 25 Feb 2025 15:56:33 GMT Job Modify Index: 201987
and
Tue, 25 Feb 2025 15:57:41 GMT +/- Job: "job"
Tue, 25 Feb 2025 15:57:41 GMT +/- Task Group: "group" (1 create/destroy update, 1 ignore)
Tue, 25 Feb 2025 15:57:41 GMT +/- Task: "task" (forces create/destroy update)
Tue, 25 Feb 2025 15:57:41 GMT +/- Config {
Tue, 25 Feb 2025 15:57:41 GMT +/- image: "ghcr.io/demvsystems/stuff@sha256:d47126837187957643d6de9219b83948f5be258a0082ab9b509ff232bb93cde7" => "ghcr.io/demvsystems/stuff@sha256:9775838ef50c805a7c7ddb333569e40744c800ac5474beeebcf67d02a4e51a06"
Tue, 25 Feb 2025 15:57:41 GMT }
Tue, 25 Feb 2025 15:57:41 GMT
Tue, 25 Feb 2025 15:57:41 GMT Scheduler dry-run:
Tue, 25 Feb 2025 15:57:41 GMT - All tasks successfully allocated.
Tue, 25 Feb 2025 15:57:41 GMT
Tue, 25 Feb 2025 15:57:41 GMT Job Modify Index: 202475
The first deployment worked as expected:
Tue, 25 Feb 2025 15:56:33 GMT nomad job run -check-index 201987 -var="project_image=ghcr.io/demvsystems/stuff@sha256:d47126837187957643d6de9219b83948f5be258a0082ab9b509ff232bb93cde7" live.nomad.hcl
Tue, 25 Feb 2025 15:56:34 GMT ==> 2025-02-25T15:56:34Z: Monitoring evaluation "063434c5"
Tue, 25 Feb 2025 15:56:34 GMT 2025-02-25T15:56:34Z: Evaluation within deployment: "5c811468"
...
Tue, 25 Feb 2025 15:56:35 GMT 2025-02-25T15:56:35Z
Tue, 25 Feb 2025 15:56:35 GMT ID = 5c811468
Tue, 25 Feb 2025 15:56:35 GMT Job ID = job
Tue, 25 Feb 2025 15:56:35 GMT Job Version = 9
Tue, 25 Feb 2025 15:56:35 GMT Status = running
Tue, 25 Feb 2025 15:56:35 GMT Description = Deployment is running
...
Tue, 25 Feb 2025 15:57:42 GMT 2025-02-25T15:57:42Z
Tue, 25 Feb 2025 15:57:42 GMT ID = 5c811468
Tue, 25 Feb 2025 15:57:42 GMT Job ID = job
Tue, 25 Feb 2025 15:57:42 GMT Job Version = 9
Tue, 25 Feb 2025 15:57:42 GMT Status = successful
Tue, 25 Feb 2025 15:57:42 GMT Description = Deployment completed successfully
but the second one did not create a new job version and finished immediately:
Tue, 25 Feb 2025 15:57:41 GMT nomad job run -check-index 202475 -var="project_image=ghcr.io/demvsystems/stuff@sha256:9775838ef50c805a7c7ddb333569e40744c800ac5474beeebcf67d02a4e51a06" live.nomad.hcl
Tue, 25 Feb 2025 15:57:42 GMT ==> 2025-02-25T15:57:42Z: Monitoring evaluation "1fc4dc97"
Tue, 25 Feb 2025 15:57:42 GMT 2025-02-25T15:57:42Z: Evaluation within deployment: "5c811468"
...
Tue, 25 Feb 2025 15:57:42 GMT 2025-02-25T15:57:42Z
Tue, 25 Feb 2025 15:57:42 GMT ID = 5c811468
Tue, 25 Feb 2025 15:57:42 GMT Job ID = job
Tue, 25 Feb 2025 15:57:42 GMT Job Version = 9
Tue, 25 Feb 2025 15:57:42 GMT Status = successful
Tue, 25 Feb 2025 15:57:42 GMT Description = Deployment completed successfully
So they had different different evaluations, but the same job version and deployment. What’s the cause for this problem? Is using an input variable not the correct way to do this?