hashicorp/nomad · error
maximum count must not be less than minimum count
Error message
maximum count must not be less than minimum count
What it means
ScalingPolicy.Validate() requires max >= min. When the policy's Max is non-negative but strictly less than Min, this error is appended to the multierror. The count range would otherwise be contradictory (the scaler could never move within it).
Solutions
- Raise `max` to be greater than or equal to `min`.
- Lower `min` if it was set too high relative to the intended max.
- Run `nomad job validate` after the fix to confirm no other policy errors remain.
Example fix
// before
scaling {
min = 5
max = 2
}
// after
scaling {
min = 2
max = 5
} Defensive patterns
Strategy: validation
Validate before calling
if policy.Min >= 0 && policy.Max >= 0 && policy.Max < policy.Min {
return fmt.Errorf("max (%d) must be >= min (%d)", policy.Max, policy.Min)
} Prevention
- Enforce min <= max in any tooling that writes scaling blocks.
- When lowering max via the autoscaler, first lower or check min.
- Keep min/max as paired (min,max) variables to avoid swapped values.
When it happens
Trigger: Submitting a scaling block like `min = 5, max = 2`, or swapping the values when copying an example, or updating max downward below the current min via the scaling policy API.
Common situations: Copy-paste mistakes in HCL; autoscaler configs edited manually where min was raised later and max was not; templated jobs with reversed interpolation of min/max variables.
Related errors
- maximum count must be specified and non-negative
- minimum count must be specified and non-negative
- missing scaling policy type
- missing target group
- missing target job
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/3d414d2f3f3693f2.
Report an issue: GitHub.
Appendix: source
Thrown at nomad/structs/structs.go:6447
return nil
}
var mErr multierror.Error
// Check policy type and target
if p.Type == "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("missing scaling policy type"))
} else {
mErr.Errors = append(mErr.Errors, p.validateType().Errors...)
}
// Check Min and Max
if p.Max < 0 {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("maximum count must be specified and non-negative"))
} else if p.Max < p.Min {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("maximum count must not be less than minimum count"))
}
if p.Min < 0 {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("minimum count must be specified and non-negative"))
}
return mErr.ErrorOrNil()
}
func (p *ScalingPolicy) validateTargetHorizontal() (mErr multierror.Error) {
if len(p.Target) == 0 {
// This is probably not a Nomad horizontal policy
return
}
// Nomad horizontal policies should have Namespace, Job and TaskGroup
if p.Target[ScalingTargetNamespace] == "" {View on GitHub (pinned to 482b49bf1a)