hashicorp/nomad · error

Job type %q does not allow migrate block

Error message

Job type %q does not allow migrate block

What it means

Nomad job validation rejects a `migrate` block on any job type other than "service". The migrate stanza controls draining/reallocation of allocations on node updates and only applies to service jobs, so its presence under a batch/sysbatch or other type triggers this multierror entry in TaskGroup.Validate.

Source

Thrown at nomad/structs/structs.go:7244

		default:
			mErr = multierror.Append(mErr, fmt.Errorf("Job type %q does not allow update block", j.Type))
		}
		if err := u.Validate(); err != nil {
			mErr = multierror.Append(mErr, err)
		}
	}

	// Validate the migration strategy
	switch j.Type {
	case JobTypeService:
		if tg.Migrate != nil {
			if err := tg.Migrate.Validate(); err != nil {
				mErr = multierror.Append(mErr, err)
			}
		}
	default:
		if tg.Migrate != nil {
			mErr = multierror.Append(mErr, fmt.Errorf("Job type %q does not allow migrate block", j.Type))
		}
	}

	// Check that there is only one leader task if any
	tasks := make(map[string]int)
	leaderTasks := 0
	mainTasks := 0
	for idx, task := range tg.Tasks {
		if task.Name == "" {
			mErr = multierror.Append(mErr, fmt.Errorf("Task %d missing name", idx+1))
		} else if existing, ok := tasks[task.Name]; ok {
			mErr = multierror.Append(mErr, fmt.Errorf("Task %d redefines '%s' from task %d", idx+1, task.Name, existing+1))
		} else {
			tasks[task.Name] = idx
		}

		if task.Leader {
			leaderTasks++

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Delete the `migrate` stanza from the task group.
  2. Or set the job `type` back to "service" if migration behavior is required.

Example fix

// before
type = "batch"
migrate {
  max_parallel = 1
}
// after
type = "batch"
# migrate block removed
Defensive patterns

Strategy: validation

Validate before calling

// Go: pre-validate before submitting
for _, tg := range job.TaskGroups {
  if job.Type != structs.JobTypeService && tg.Migrate != nil {
    return fmt.Errorf("group %q: migrate block only valid for service jobs", tg.Name)
  }
}

Prevention

When it happens

Trigger: Submitting a job whose task group defines a `migrate` stanza while `job type` is not "service" (e.g. batch, sysbatch).

Common situations: Template reuse: a migrate stanza copied from a service job into a batch job; retyping a service job to batch while keeping migration config; generated specs that always include migrate settings.

Related errors


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