hashicorp/nomad · error

Job task group %s has count %d. Count cannot exceed 1 with s

Error message

Job task group %s has count %d. Count cannot exceed 1 with system scheduler

What it means

Job.Validate() rejects system job groups with count greater than 1: 'Job task group %s has count %d. Count cannot exceed 1 with system scheduler'. System jobs run one allocation per eligible node, so the count field is ignored/meaningless beyond 1.

Source

Thrown at nomad/structs/structs.go:4841

	// Check for duplicate task groups
	taskGroups := make(map[string]int)
	for idx, tg := range j.TaskGroups {
		if tg.Name == "" {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("Job task group %d missing name", idx+1))
		} else if existing, ok := taskGroups[tg.Name]; ok {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("Job task group %d redefines '%s' from group %d", idx+1, tg.Name, existing+1))
		} else {
			taskGroups[tg.Name] = idx
		}

		if tg.ShutdownDelay != nil && *tg.ShutdownDelay < 0 {
			mErr.Errors = append(mErr.Errors, errors.New("ShutdownDelay must be a positive value"))
		}

		if j.Type == "system" && tg.Count > 1 {
			mErr.Errors = append(mErr.Errors,
				fmt.Errorf("Job task group %s has count %d. Count cannot exceed 1 with system scheduler",
					tg.Name, tg.Count))
		}
	}

	// Validate the task group
	for _, tg := range j.TaskGroups {
		if err := tg.Validate(j); err != nil {
			outer := fmt.Errorf("Task group %s validation failed: %v", tg.Name, err)
			mErr.Errors = append(mErr.Errors, outer)
		}
	}

	// Validate periodic is only used with batch or sysbatch jobs.
	if j.IsPeriodic() && j.Periodic.Enabled {
		if j.Type != JobTypeBatch && j.Type != JobTypeSysBatch {
			mErr.Errors = append(mErr.Errors, fmt.Errorf(
				"Periodic can only be used with %q or %q scheduler", JobTypeBatch, JobTypeSysBatch,
			))

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Remove the count field from the system job's group (or set it to 1/leave default)
  2. Keep count > 1 only on service or batch jobs
  3. If scaling across nodes is the goal, remember system jobs automatically run on every eligible node
  4. Run 'nomad job validate' before submission

Example fix

// before
job "sys" {
  type = "system"
  group "agent" { count = 3 }
}
// after
job "sys" {
  type = "system"
  group "agent" {}
}
Defensive patterns

Strategy: validation

Validate before calling

if job.Type == "system" {
    for _, tg := range job.TaskGroups {
        if tg.Count > 1 {
            return fmt.Errorf("group %s: count must be <= 1 for system jobs", tg.Name)
        }
    }
}
return nil

Try / catch

if err := job.Validate(); err != nil {
    if strings.Contains(err.Error(), "Count cannot exceed 1 with system scheduler") {
        return ErrSystemJobCount
    }
    return err
}

Prevention

When it happens

Trigger: Submitting a job with type = "system" where any TaskGroup has Count > 1, typically because the group was copied from a service job or Count was set explicitly.

Common situations: Converting a service job to system without removing count, provisioning tools that always emit count = N, misunderstanding that system scheduler derives count from node eligibility.

Related errors


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