{"record":{"id":"6315d399501e2e93","repo":"hashicorp/nomad","slug":"total-count-was-greater-than-configured-job-max-co","errorCode":null,"errorMessage":"total count was greater than configured job_max_count: %d > %d","messagePattern":"total count was greater than configured job_max_count: (.+?) > (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/job_endpoint.go","lineNumber":1049,"sourceCode":"\t\t\t\t\tfmt.Sprintf(\"group count was less than scaling policy minimum: %d < %d\",\n\t\t\t\t\t\t*args.Count, group.Scaling.Min))\n\t\t\t}\n\t\t\tif group.Scaling.Max < *args.Count {\n\t\t\t\treturn structs.NewErrRPCCoded(400,\n\t\t\t\t\tfmt.Sprintf(\"group count was greater than scaling policy maximum: %d > %d\",\n\t\t\t\t\t\t*args.Count, group.Scaling.Max))\n\t\t\t}\n\t\t}\n\n\t\t// Ensure that JobMaxCount is respected.\n\t\tnewCount := int(*args.Count)\n\t\ttotalCount := 0\n\t\tfor _, tg := range job.TaskGroups {\n\t\t\ttotalCount += tg.Count\n\t\t}\n\t\ttotalCount = totalCount - group.Count + newCount\n\t\tif j.srv.config.JobMaxCount > 0 && totalCount > j.srv.config.JobMaxCount {\n\t\t\treturn fmt.Errorf(\"total count was greater than configured job_max_count: %d > %d\", totalCount, j.srv.config.JobMaxCount)\n\t\t}\n\n\t\t// Update group count\n\t\tgroup.Count = newCount\n\t\tjob.SubmitTime = now\n\n\t\t// Block scaling event if there's an active deployment\n\t\tdeployment, err := snap.LatestDeploymentByJobID(ws, namespace, args.JobID)\n\t\tif err != nil {\n\t\t\tj.logger.Error(\"unable to lookup latest deployment\", \"error\", err)\n\t\t\treturn err\n\t\t}\n\n\t\tif deployment != nil && deployment.Active() && deployment.JobCreateIndex == job.CreateIndex {\n\t\t\treturn structs.NewErrRPCCoded(400, \"job scaling blocked due to active deployment\")\n\t\t}\n\n\t\t// If JobModifyIndex set, check it before trying to apply","sourceCodeStart":1031,"sourceCodeEnd":1067,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/job_endpoint.go#L1031-L1067","documentation":"The Job.Scale RPC enforces the agent's job_max_count server configuration: after applying the new group count, the job's total task-group count may not exceed the limit. Nomad throws this to cap cluster resource usage when a scale request would push the summed counts past the configured maximum.","triggerScenarios":"POST /v1/job/<id>/scale requesting a Target 'Count' such that (sum of all group counts) - (current group count) + newCount > job_max_count — e.g. scaling a group to 100 when job_max_count is 50 and other groups already use 10.","commonSituations":"Autoscalers (Nomad Autoscaler) scaling past a limit set by cluster operators; default job_max_count lowered for safety in shared clusters; legitimate growth that outlived the original capacity plan.","solutions":["Raise job_max_count in the server configuration block and restart/reload Nomad servers","Scale down another task group so the total stays under the limit","Request a smaller newCount for this group","If the limit is intentional, adjust the autoscaler policy bounds to respect it"],"exampleFix":"// before\n# nomad server config\nserver { job_max_count = 50 }\n// after\n# nomad server config\nserver { job_max_count = 200 }","handlingStrategy":"validation","validationCode":"job, _, _ := client.Jobs().Info(jobID, nil)\ntotal := 0\nfor _, tg := range job.TaskGroups { total += *tg.Count }\nnewTotal := total - *group.Count + newCount\nif newTotal > jobMaxCountLimit { return fmt.Errorf(\"new total %d exceeds job_max_count %d\", newTotal, jobMaxCountLimit) }","typeGuard":null,"tryCatchPattern":"_, _, err := client.Jobs().Scale(jobID, jobID, group, nil, uint64(newCount), \"api\", false, nil)\nif err != nil && strings.Contains(err.Error(), \"job_max_count\") {\n\treturn fmt.Errorf(\"scale rejected: raise job_max_count or scale down other groups\")\n}","preventionTips":["Compute projected totals client-side against the known job_max_count","Align autoscaler policy max bounds with the server limit","Review job_max_count when workloads grow"],"tags":["nomad","scaling","configuration-limit","capacity"],"backgroundTag":"quota-exceeded","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"}