hashicorp/nomad · error

Failed to retrieve evaluations for job %q: %w

Error message

Failed to retrieve evaluations for job %q: %w

What it means

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.

Source

Thrown at command/job_restart.go:1023

// Returns an error in errCh if anything goes wrong or if there are placement
// failures for the allocation task group.
func (c *JobRestartCommand) monitorPlacementFailures(
	ctx context.Context,
	alloc AllocationListStubWithJob,
	index uint64,
	errCh chan<- error,
) {
	q := &api.QueryOptions{WaitIndex: index}
	for {
		select {
		case <-ctx.Done():
			return
		default:
		}

		evals, qm, err := c.client.Jobs().Evaluations(alloc.JobID, q)
		if err != nil {
			errCh <- fmt.Errorf("Failed to retrieve evaluations for job %q: %w", alloc.JobID, err)
			return
		}

		for _, eval := range evals {
			select {
			case <-ctx.Done():
				return
			default:
			}

			// Skip evaluations created before the allocation was stopped or
			// that are not blocked.
			if eval.CreateIndex < index || eval.Status != api.EvalStatusBlocked {
				continue
			}

			failures := eval.FailedTGAllocs[alloc.TaskGroup]
			if failures != nil {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check Nomad agent health and network connectivity, then re-run the restart
  2. Verify the ACL token can read job evaluations
  3. Increase query timeouts/waits if the RPC is timing out
  4. Confirm the job was not deleted concurrently
Defensive patterns

Strategy: retry

Validate before calling

if _, _, err := client.Jobs().Evaluations(jobID, nil); err != nil {
    return fmt.Errorf("cannot poll evaluations for %s: %w", jobID, err)
}

Try / catch

evals, qm, err := client.Jobs().Evaluations(jobID, q)
if err != nil {
    if isTransient(err) {
        time.Sleep(pollInterval)
        continue // bounded retries
    }
    errCh <- fmt.Errorf("eval polling aborted: %w", err)
    return
}

Prevention

When it happens

Trigger: 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.

Common situations: Long-running restart spanning an agent restart or deployment; network flakiness between CLI and server; token revoked mid-operation.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/3c6693261f563104. Report an issue: GitHub.