hashicorp/nomad · error

task group %q doesn't exist or it has no allocations

Error message

task group %q doesn't exist or it has no allocations

What it means

Validation error in getRandomJobAlloc: after filtering the job's allocations by the given task group, none match, so the named task group either doesn't exist in the job or its allocations have all been stopped.

Source

Thrown at command/alloc_fs.go:400

	if err != nil {
		return nil, fmt.Errorf("error querying job %q: %w", jobID, err)
	}

	// Check that the job actually has allocations
	if len(allocs) == 0 {
		return nil, fmt.Errorf("job %q doesn't exist or it has no allocations", jobID)
	}

	if taskGroupName != "" {
		var filteredAllocs []*api.AllocationListStub
		for _, alloc := range allocs {
			if alloc.TaskGroup == taskGroupName {
				filteredAllocs = append(filteredAllocs, alloc)
			}
		}
		allocs = filteredAllocs
		if len(allocs) == 0 {
			return nil, fmt.Errorf("task group %q doesn't exist or it has no allocations", taskGroupName)
		}
	}

	for _, v := range allocs {
		if v.ClientStatus == "running" {
			runningAllocs = append(runningAllocs, v)
		}
	}
	// If we don't have any allocations running, use dead allocations
	if len(runningAllocs) < 1 {
		runningAllocs = allocs
	}

	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	alloc := runningAllocs[r.Intn(len(runningAllocs))]

	return alloc, err
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check the task group name spelling with nomad job status <job>
  2. Omit the task group filter to use any allocation of the job
  3. Use a job that has live allocations in the requested task group
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at command/alloc_fs.go:400 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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