hashicorp/nomad · error

Task cannot be named "alloc"

Error message

Task cannot be named "alloc"

What it means

Task.Validate forbids naming a task "alloc" because it collides with the alloc/ directory used for shared allocation scratch space, breaking task filesystem isolation. The check is an exact match on t.Name.

Source

Thrown at nomad/structs/structs.go:8237

		t.Identity.Canonicalize()
	}
}

func (t *Task) GoString() string {
	return fmt.Sprintf("*%#v", *t)
}

// Validate is used to check a task for reasonable configuration
func (t *Task) Validate(jobType string, tg *TaskGroup) error {
	var mErr multierror.Error
	if t.Name == "" {
		mErr.Errors = append(mErr.Errors, errors.New("Missing task name"))
	}

	// Tasks cannot be named "alloc" as this conflicts with and breaks task
	// filesystem isolation features.
	if t.Name == "alloc" {
		mErr.Errors = append(mErr.Errors, errors.New("Task cannot be named \"alloc\""))
	}
	if strings.ContainsAny(t.Name, `/\`) {
		// We enforce this so that when creating the directory on disk it will
		// not have any slashes.
		mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include slashes"))
	} else if strings.Contains(t.Name, "\000") {
		mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include null characters"))
	}
	if t.Driver == "" {
		mErr.Errors = append(mErr.Errors, errors.New("Missing task driver"))
	}
	if t.KillTimeout < 0 {
		mErr.Errors = append(mErr.Errors, errors.New("KillTimeout must be a positive value"))
	} else {
		// Validate the group's update strategy does not conflict with the
		// task's kill_timeout for service jobs.
		//
		// progress_deadline = 0 has a special meaning so it should not be

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Rename the task to something else, e.g. task "app".
  2. Update references to the task name (service names, templates, log references).
  3. Re-validate the job.

Example fix

// before
task "alloc" {
  driver = "exec"
}
// after
task "allocator" {
  driver = "exec"
}
Defensive patterns

Strategy: validation

Validate before calling

if t.Name == "alloc" {
  return errors.New("'alloc' is a reserved task name")
}

Type guard

func isReservedName(t *structs.Task) bool {
  return t.Name == "alloc"
}

Prevention

When it happens

Trigger: A task block named `alloc` in HCL/JSON, e.g. task "alloc" { ... }, submitted to a Nomad cluster.

Common situations: Naming a task after the allocation concept; generated configs using generic placeholder names.

Related errors


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