{"record":{"id":"1751e57d0a89fe1c","repo":"hashicorp/nomad","slug":"task-group-q-does-not-exist-in-job-q","errorCode":null,"errorMessage":"task group %q does not exist in job %q","messagePattern":"task group %q does not exist in job %q","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/health_hook.go","lineNumber":138,"sourceCode":"\nfunc (h *allocHealthWatcherHook) Name() string {\n\treturn \"alloc_health_watcher\"\n}\n\n// init starts the allochealth.Tracker and watchHealth goroutine on either\n// Prerun or Update. Caller must set/update alloc and logger fields.\n//\n// Not threadsafe so the caller should lock since Updates occur concurrently.\nfunc (h *allocHealthWatcherHook) init(allocEnv *taskenv.TaskEnv) error {\n\t// No need to watch health as it's already set\n\tif h.healthSetter.HasHealth() {\n\t\th.logger.Trace(\"not watching; already has health set\")\n\t\treturn nil\n\t}\n\n\ttg := h.alloc.Job.LookupTaskGroup(h.alloc.TaskGroup)\n\tif tg == nil {\n\t\treturn fmt.Errorf(\"task group %q does not exist in job %q\", h.alloc.TaskGroup, h.alloc.Job.ID)\n\t}\n\n\th.isDeploy = h.alloc.DeploymentID != \"\"\n\n\t// No need to watch allocs for deployments that rely on operators\n\t// manually setting health\n\tif h.isDeploy && (tg.Update.IsEmpty() || tg.Update.HealthCheck == structs.UpdateStrategyHealthCheck_Manual) {\n\t\treturn nil\n\t}\n\n\t// Define the deadline, health method, min healthy time from the\n\t// deployment if this is a deployment; otherwise from the migration\n\t// strategy.\n\tdeadline, useChecks, minHealthyTime := getHealthParams(time.Now(), tg, h.isDeploy)\n\n\t// Create a context that is canceled when the tracker should shutdown.\n\tctx := context.Background()\n\tctx, h.cancelFn = context.WithCancel(ctx)","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/health_hook.go#L120-L156","documentation":"The health_hook's init looks up the allocation's task group in the job struct via Job.LookupTaskGroup. If the group name recorded on the allocation doesn't exist in the job definition, the hook cannot build its health watches and returns this error during Prerun or Update.","triggerScenarios":"h.alloc.TaskGroup is not found among h.alloc.Job.TaskGroups — the allocation's stored job has no task group matching alloc.TaskGroup.","commonSituations":"Corrupted or truncated allocation state in the client state store; job submissions that renamed/removed task groups while stale allocations exist; manually edited state store data; bugs in job-serialization during client restore.","solutions":["Verify the job definition still contains the task group: `nomad job inspect <job>`.","Stop/clean up the stale allocation (`nomad alloc stop <alloc>` or remove it from the client state store) and reschedule.","Resubmit the job so allocations are regenerated against the current spec.","If it recurs after client restarts, check the client data_dir state store for corruption and restore from a clean state."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if alloc.Job.LookupTaskGroup(alloc.TaskGroup) == nil {\n    return fmt.Errorf(\"task group %q missing from job %q; resubmit job\", alloc.TaskGroup, alloc.Job.ID)\n}","typeGuard":"func taskGroupExists(job *structs.Job, name string) bool {\n    return job != nil && job.LookupTaskGroup(name) != nil\n}","tryCatchPattern":"if err := hook.Prerun(); err != nil && strings.Contains(err.Error(), \"does not exist in job\") {\n    // stale alloc: stop it and reschedule a fresh allocation\n}","preventionTips":["Resubmit jobs after renaming/removing task groups.","Clean stale allocations from the client state store after job edits.","Avoid manually editing client state files.","Use nomad alloc stop for orphaned allocations rather than deleting state directly."],"tags":["nomad","allocrunner","task-group","state"],"backgroundTag":"task-group-not-found","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"}