{"record":{"id":"807db80fdb4248ee","repo":"hashicorp/nomad","slug":"task-q-in-group-q-defines-services-but-has-no-s","errorCode":null,"errorMessage":"task %q in group %q defines services, but has no shutdown_delay set","messagePattern":"task %q in group %q defines services, but has no shutdown_delay set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"nomad/structs/structs.go","lineNumber":4947,"sourceCode":"\n\tfor _, t := range tg.Tasks {\n\t\tif _, ok := referencedTaskIDs[t.Name]; ok && t.ShutdownDelay == 0 {\n\t\t\twarnings = append(warnings, fmt.Errorf(\n\t\t\t\t\"group %q references task %q in a service definition, but the task has no shutdown_delay set\",\n\t\t\t\ttg.Name, t.Name))\n\t\t}\n\n\t\tif t.ShutdownDelay > 0 {\n\t\t\tanyTaskHasShutdownDelay = true\n\t\t} else if len(t.Services) > 0 {\n\t\t\twarnings = append(warnings, fmt.Errorf(\n\t\t\t\t\"task %q in group %q defines services, but has no shutdown_delay set\",\n\t\t\t\tt.Name, tg.Name))\n\t\t}\n\t}\n\n\tif hasUnscopedGroupService && !hasGroupShutdownDelay && !anyTaskHasShutdownDelay {\n\t\twarnings = append(warnings, fmt.Errorf(\n\t\t\t\"group %q defines services, but neither the group nor any of its tasks have shutdown_delay set\", tg.Name))\n\t}\n\n\treturn warnings\n}\n\n// Warnings returns a list of warnings that may be from dubious settings or\n// deprecation warnings.\nfunc (j *Job) Warnings() error {\n\tvar mErr multierror.Error\n\n\t// Check the groups\n\thasAutoPromote, allAutoPromote := false, true\n\n\tfor _, tg := range j.TaskGroups {\n\t\tif err := tg.Warnings(j); err != nil {\n\t\t\touter := fmt.Errorf(\"Group %q has warnings: %v\", tg.Name, err)\n\t\t\tmErr.Errors = append(mErr.Errors, outer)","sourceCodeStart":4929,"sourceCodeEnd":4965,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L4929-L4965","documentation":"Although the snippet's message text at structs.go:4947 is 'task %q in group %q defines services, but has no shutdown_delay set', the source region shows the group-level warning that fires when the group has unscoped (group-level) services and neither the group nor any of its tasks set shutdown_delay — i.e. 'group %q defines services, but neither the group nor any of its tasks have shutdown_delay set'. It is a warning appended by TaskGroup.Warnings.","triggerScenarios":"A task group defines group-level `service` blocks (hasUnscopedGroupService) while tg.ShutdownDelay is unset and no task in the group sets ShutdownDelay > 0. Rendered via job validation warnings and Meta.FormatWarnings.","commonSituations":"Group-level connect services with default sidecars; groups migrated from job-level service configs; operators unaware group-level shutdown_delay exists.","solutions":["Set `shutdown_delay` on the task group, or on at least one task in the group.","Or set it on the connect sidecar_task if that is the relevant process.","Re-validate with `nomad job validate` to confirm."],"exampleFix":"// before\ngroup \"web\" {\n  service { name = \"web\"; connect { sidecar_service {} } }\n}\n// after\ngroup \"web\" {\n  shutdown_delay = \"5s\"\n  service { name = \"web\"; connect { sidecar_service {} } }\n}","handlingStrategy":"validation","validationCode":"if len(group.Services) > 0 && group.ShutdownDelay == 0 &&\n   !anyTaskHasShutdownDelay(group) {\n    log.Warnf(\"group %q defines services with no shutdown_delay anywhere\", group.Name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set shutdown_delay at the group level for groups with group services.","Document that either group or per-task shutdown_delay is required for service groups.","Run validation warnings check in CI pipelines."],"tags":["nomad","task-group","services","shutdown-delay"],"backgroundTag":"missing-shutdown-delay","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}