{"record":{"id":"66d1bab1a95b12af","repo":"hashicorp/nomad","slug":"job-task-group-s-has-count-d-count-cannot-excee","errorCode":null,"errorMessage":"Job task group %s has count %d. Count cannot exceed 1 with system scheduler","messagePattern":"Job task group (.+?) has count (.+?)\\. Count cannot exceed 1 with system scheduler","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":4841,"sourceCode":"\n\t// Check for duplicate task groups\n\ttaskGroups := make(map[string]int)\n\tfor idx, tg := range j.TaskGroups {\n\t\tif tg.Name == \"\" {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Job task group %d missing name\", idx+1))\n\t\t} else if existing, ok := taskGroups[tg.Name]; ok {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Job task group %d redefines '%s' from group %d\", idx+1, tg.Name, existing+1))\n\t\t} else {\n\t\t\ttaskGroups[tg.Name] = idx\n\t\t}\n\n\t\tif tg.ShutdownDelay != nil && *tg.ShutdownDelay < 0 {\n\t\t\tmErr.Errors = append(mErr.Errors, errors.New(\"ShutdownDelay must be a positive value\"))\n\t\t}\n\n\t\tif j.Type == \"system\" && tg.Count > 1 {\n\t\t\tmErr.Errors = append(mErr.Errors,\n\t\t\t\tfmt.Errorf(\"Job task group %s has count %d. Count cannot exceed 1 with system scheduler\",\n\t\t\t\t\ttg.Name, tg.Count))\n\t\t}\n\t}\n\n\t// Validate the task group\n\tfor _, tg := range j.TaskGroups {\n\t\tif err := tg.Validate(j); err != nil {\n\t\t\touter := fmt.Errorf(\"Task group %s validation failed: %v\", tg.Name, err)\n\t\t\tmErr.Errors = append(mErr.Errors, outer)\n\t\t}\n\t}\n\n\t// Validate periodic is only used with batch or sysbatch jobs.\n\tif j.IsPeriodic() && j.Periodic.Enabled {\n\t\tif j.Type != JobTypeBatch && j.Type != JobTypeSysBatch {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\n\t\t\t\t\"Periodic can only be used with %q or %q scheduler\", JobTypeBatch, JobTypeSysBatch,\n\t\t\t))","sourceCodeStart":4823,"sourceCodeEnd":4859,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L4823-L4859","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the count field from the system job's group (or set it to 1/leave default)","Keep count > 1 only on service or batch jobs","If scaling across nodes is the goal, remember system jobs automatically run on every eligible node","Run 'nomad job validate' before submission"],"exampleFix":"// before\njob \"sys\" {\n  type = \"system\"\n  group \"agent\" { count = 3 }\n}\n// after\njob \"sys\" {\n  type = \"system\"\n  group \"agent\" {}\n}","handlingStrategy":"validation","validationCode":"if job.Type == \"system\" {\n    for _, tg := range job.TaskGroups {\n        if tg.Count > 1 {\n            return fmt.Errorf(\"group %s: count must be <= 1 for system jobs\", tg.Name)\n        }\n    }\n}\nreturn nil","typeGuard":null,"tryCatchPattern":"if err := job.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"Count cannot exceed 1 with system scheduler\") {\n        return ErrSystemJobCount\n    }\n    return err\n}","preventionTips":["Omit count entirely on system job groups","Use distinct job templates for system vs service types","Warn in CI when type=system and any count > 1"],"tags":["nomad","job-validation","system-job","count"],"backgroundTag":"nomad-job-validation-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}