From 608094af7361ad2e0aee67c438a960ed90f87c95 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Wed, 6 May 2026 08:18:50 +0100 Subject: [PATCH] cli: add `shutdown_delay` to job init outputs. Nomad recently added a warning to the CLI output when a job includes a service in a group/task that doesn't have a shutdown delay configured. This change brings the Nomad example job specs created by the init command inline with our reccommendations. --- command/asset/connect-short.nomad.hcl | 6 ++++-- command/asset/connect.nomad.hcl | 22 ++++++++++++++++++++++ command/asset/example.nomad.hcl | 11 +++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/command/asset/connect-short.nomad.hcl b/command/asset/connect-short.nomad.hcl index 91a1948be81..c5a643558b0 100644 --- a/command/asset/connect-short.nomad.hcl +++ b/command/asset/connect-short.nomad.hcl @@ -15,7 +15,8 @@ job "countdash" { } task "web" { - driver = "docker" + driver = "docker" + shutdown_delay = "10s" config { image = "hashicorpdev/counter-api:v3" @@ -51,7 +52,8 @@ job "countdash" { } task "dashboard" { - driver = "docker" + driver = "docker" + shutdown_delay = "10s" env { COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}" diff --git a/command/asset/connect.nomad.hcl b/command/asset/connect.nomad.hcl index 935a23d4c94..8e2344b583c 100644 --- a/command/asset/connect.nomad.hcl +++ b/command/asset/connect.nomad.hcl @@ -122,6 +122,17 @@ job "countdash" { auth_soft_fail = true } + # Specifies the duration to wait when killing a task between removing its + # service registrations from Consul or Nomad, and sending it a shutdown + # signal. Ideally services would fail health checks once they receive a + # shutdown signal. + # + # For more information on the "shutdown_delay" parameter, refer to: + # + # https://developer.hashicorp.com/nomad/docs/job-specification/task#shutdown_delay + # + shutdown_delay = "10s" + # The "resources" block describes the requirements a task needs to # execute. Resource requirements include attributes such as memory, cpu, # cores, and devices. @@ -232,6 +243,17 @@ job "countdash" { image = "hashicorpdev/counter-dashboard:v3" auth_soft_fail = true } + + # Specifies the duration to wait when killing a task between removing its + # service registrations from Consul or Nomad, and sending it a shutdown + # signal. Ideally services would fail health checks once they receive a + # shutdown signal. + # + # For more information on the "shutdown_delay" parameter, refer to: + # + # https://developer.hashicorp.com/nomad/docs/job-specification/task#shutdown_delay + # + shutdown_delay = "10s" } } } diff --git a/command/asset/example.nomad.hcl b/command/asset/example.nomad.hcl index 1e3136e959a..ab17ecaafe9 100644 --- a/command/asset/example.nomad.hcl +++ b/command/asset/example.nomad.hcl @@ -300,6 +300,17 @@ job "example" { auth_soft_fail = true } + # Specifies the duration to wait when killing a task between removing its + # service registrations from Consul or Nomad, and sending it a shutdown + # signal. Ideally services would fail health checks once they receive a + # shutdown signal. + # + # For more information on the "shutdown_delay" parameter, refer to: + # + # https://developer.hashicorp.com/nomad/docs/job-specification/task#shutdown_delay + # + shutdown_delay = "10s" + # The "artifact" block instructs Nomad to download an artifact from a # remote source prior to starting the task. This provides a convenient # mechanism for downloading configuration files or data needed to run the