{"record":{"id":"3c6693261f563104","repo":"hashicorp/nomad","slug":"failed-to-retrieve-evaluations-for-job-q-w","errorCode":null,"errorMessage":"Failed to retrieve evaluations for job %q: %w","messagePattern":"Failed to retrieve evaluations for job %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/job_restart.go","lineNumber":1023,"sourceCode":"// Returns an error in errCh if anything goes wrong or if there are placement\n// failures for the allocation task group.\nfunc (c *JobRestartCommand) monitorPlacementFailures(\n\tctx context.Context,\n\talloc AllocationListStubWithJob,\n\tindex uint64,\n\terrCh chan<- error,\n) {\n\tq := &api.QueryOptions{WaitIndex: index}\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\tdefault:\n\t\t}\n\n\t\tevals, qm, err := c.client.Jobs().Evaluations(alloc.JobID, q)\n\t\tif err != nil {\n\t\t\terrCh <- fmt.Errorf(\"Failed to retrieve evaluations for job %q: %w\", alloc.JobID, err)\n\t\t\treturn\n\t\t}\n\n\t\tfor _, eval := range evals {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t}\n\n\t\t\t// Skip evaluations created before the allocation was stopped or\n\t\t\t// that are not blocked.\n\t\t\tif eval.CreateIndex < index || eval.Status != api.EvalStatusBlocked {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfailures := eval.FailedTGAllocs[alloc.TaskGroup]\n\t\t\tif failures != nil {","sourceCodeStart":1005,"sourceCodeEnd":1041,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/job_restart.go#L1005-L1041","documentation":"monitorPlacementFailures polls Jobs().Evaluations for the job to detect placement failures while waiting for a replacement alloc. If the polling RPC fails, the error is written to errCh as 'Failed to retrieve evaluations for job <id>: <cause>' and the monitor exits.","triggerScenarios":"Repeated Evaluations API calls fail — agent goes away mid-restart, request timeout (query options), ACL token lacks job read permissions, or job ID no longer exists.","commonSituations":"Long-running restart spanning an agent restart or deployment; network flakiness between CLI and server; token revoked mid-operation.","solutions":["Check Nomad agent health and network connectivity, then re-run the restart","Verify the ACL token can read job evaluations","Increase query timeouts/waits if the RPC is timing out","Confirm the job was not deleted concurrently"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if _, _, err := client.Jobs().Evaluations(jobID, nil); err != nil {\n    return fmt.Errorf(\"cannot poll evaluations for %s: %w\", jobID, err)\n}","typeGuard":null,"tryCatchPattern":"evals, qm, err := client.Jobs().Evaluations(jobID, q)\nif err != nil {\n    if isTransient(err) {\n        time.Sleep(pollInterval)\n        continue // bounded retries\n    }\n    errCh <- fmt.Errorf(\"eval polling aborted: %w\", err)\n    return\n}","preventionTips":["Use bounded retries with backoff on evaluation polling","Keep the agent reachable for the duration of the restart","Ensure the ACL token can read job evaluations","Avoid deleting the job while a restart is in flight"],"tags":["nomad","api","evaluation","polling","network"],"backgroundTag":"evaluations-fetch-failed","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"}