{"record":{"id":"96e4b9b97e224862","repo":"hashicorp/nomad","slug":"no-task-resources-found-on-allocation","errorCode":null,"errorMessage":"no task resources found on allocation","messagePattern":"no task resources found on allocation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"client/allocrunner/taskrunner/task_runner.go","lineNumber":449,"sourceCode":"\t\tshutdownDelayCancelFn:   config.ShutdownDelayCancelFn,\n\t\tserviceRegWrapper:       config.ServiceRegWrapper,\n\t\tgetter:                  config.Getter,\n\t\twranglers:               config.Wranglers,\n\t\twidmgr:                  config.WIDMgr,\n\t\tusers:                   config.Users,\n\t}\n\n\t// Create the logger based on the allocation ID\n\ttr.logger = config.Logger.Named(\"task_runner\").With(\"task\", config.Task.Name)\n\n\t// Create the pauser\n\ttr.pauser = newPauseGate(tr)\n\n\ttr.setHookStatsHandler(config.Alloc.Namespace)\n\n\t// Pull out the task's resources\n\tif tr.alloc.AllocatedResources == nil {\n\t\treturn nil, fmt.Errorf(\"no task resources found on allocation\")\n\t}\n\n\tif _, ok := tr.alloc.AllocatedResources.Tasks[tr.taskName]; !ok {\n\t\treturn nil, fmt.Errorf(\"no task resources found on allocation\")\n\t}\n\n\ttr.taskResources = tr.alloc.AllocatedResources.Tasks[tr.taskName].Copy()\n\n\t// Build the restart tracker.\n\trp := config.Task.RestartPolicy\n\tif rp == nil {\n\t\ttg := tr.alloc.Job.LookupTaskGroup(tr.alloc.TaskGroup)\n\t\tif tg == nil {\n\t\t\ttr.logger.Error(\"alloc missing task group\")\n\t\t\treturn nil, fmt.Errorf(\"alloc missing task group\")\n\t\t}\n\t\trp = tg.RestartPolicy\n\t}","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/taskrunner/task_runner.go#L431-L467","documentation":"NewTaskRunner validates that the allocation carries AllocatedResources before building the runner. If tr.alloc.AllocatedResources is nil, the alloc has no resource assignment at all (malformed, pre-0.9-style, or partially written allocation), so the task cannot be started. The identical message is reused for the missing-task-entry case (error 709).","triggerScenarios":"Creating a task runner via NewTaskRunner for an allocation whose AllocatedResources field is nil — e.g. an allocation object restored from an old/partially written state store, or an alloc handed to the client without a completed resources fit.","commonSituations":"Nomad client state (allocs dir / bolt state DB) containing allocations written by an older Nomad version then replayed after upgrade; corrupted or manually edited client state; server-side bug or downgrade producing allocs without AllocatedResources.","solutions":["Inspect the alloc (nomad alloc status -json <id>) and confirm AllocatedResources is null; if so, resync by stopping/forcing the alloc (nomad alloc stop) so the server creates a replacement.","Upgrade server and clients to matching, current Nomad versions — pre-0.9 allocs used Resources/TaskResources fields that no longer satisfy this path.","If a client state corruption is suspected, stop the agent, back up and remove/repair the client state DB for the bad alloc, then restart the agent.","Check server logs for the allocation creation path if it reproduces on fresh allocs (possible scheduler/upgrade bug)."],"exampleFix":"// before: stale alloc lacking AllocatedResources replayed from old client state\nAllocatedResources: nil\n// after: stop and let the scheduler place a fresh alloc\n$ nomad alloc stop <alloc-id>  // new alloc gets AllocatedResources populated","handlingStrategy":"validation","validationCode":"// guard before building task runners from a client-side alloc\nif alloc.AllocatedResources == nil {\n    return fmt.Errorf(\"alloc %s has no AllocatedResources; resync from server\", alloc.ID)\n}","typeGuard":"func allocHasResources(a *structs.Allocation) bool {\n    return a != nil && a.AllocatedResources != nil && len(a.AllocatedResources.Tasks) > 0\n}","tryCatchPattern":null,"preventionTips":["Upgrade clients and servers together; never replay pre-0.9 client state onto new agents.","Back up the client state dir before agent upgrades.","Validate allocs with nomad alloc status -json after upgrades and stop/recreate any with null AllocatedResources.","Avoid manual edits to client state stores."],"tags":["nomad","taskrunner","allocation","resources"],"backgroundTag":"missing-allocated-resources","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"}