hashicorp/nomad · error
capacity_max (%d) must be larger than capacity_min (%d)
Error message
capacity_max (%d) must be larger than capacity_min (%d)
What it means
HostVolume.Validate found the requested maximum capacity smaller than the requested minimum; capacity_max must be greater than or equal to capacity_min for a coherent volume request.
Source
Thrown at nomad/structs/host_volumes.go:147
}
// Validate verifies that the submitted HostVolume spec has valid field values,
// without validating any changes or state (see ValidateUpdate).
func (hv *HostVolume) Validate() error {
var mErr *multierror.Error
if hv.ID != "" && !helper.IsUUID(hv.ID) {
mErr = multierror.Append(mErr, fmt.Errorf("invalid ID %q", hv.ID))
}
if hv.Name == "" {
mErr = multierror.Append(mErr, errors.New("missing name"))
}
if hv.RequestedCapacityMaxBytes < hv.RequestedCapacityMinBytes {
mErr = multierror.Append(mErr, fmt.Errorf(
"capacity_max (%d) must be larger than capacity_min (%d)",
hv.RequestedCapacityMaxBytes, hv.RequestedCapacityMinBytes))
}
for _, cap := range hv.RequestedCapabilities {
err := cap.Validate()
if err != nil {
mErr = multierror.Append(mErr, err)
}
}
for _, constraint := range hv.Constraints {
if err := constraint.Validate(); err != nil {
mErr = multierror.Append(mErr, fmt.Errorf("invalid constraint: %v", err))
}
switch constraint.Operand {
case ConstraintDistinctHosts, ConstraintDistinctProperty:
mErr = multierror.Append(mErr, fmt.Errorf(
"invalid constraint %s: host volumes of the same name are always on distinct hosts", constraint.Operand))View on GitHub (pinned to 482b49bf1a)
Solutions
- Set capacity_max >= capacity_min in the volume request
- Leave capacity_max unset if only a fixed capacity is needed
Example fix
// before minBytes = 107374182400; maxBytes = 1073741824 // after minBytes = 1073741824; maxBytes = 107374182400
Defensive patterns
Strategy: validation
Validate before calling
if hv.RequestedCapacityMaxBytes < hv.RequestedCapacityMinBytes {
return fmt.Errorf("capacity_max %d < capacity_min %d", hv.RequestedCapacityMaxBytes, hv.RequestedCapacityMinBytes)
} Try / catch
if err := hv.Validate(); err != nil {
return fmt.Errorf("check capacity_min/max ordering: %w", err)
} Prevention
- Always set max >= min
- Centralize GiB->bytes conversion in one helper
- Unit-test capacity struct construction
When it happens
Trigger: Setting capacity_max below capacity_min in a host volume's requested capacity range, then validating/registering the volume.
Common situations: Swapped arguments when constructing the struct programmatically, unit mistakes (GB vs bytes) making the 'max' numerically smaller, or template variables resolved in the wrong order.
Related errors
- validating volume %q against state failed: %v
- volume validation failed: %w
- volume validation failed: no such namespace %q
- node ID %q is not in pool %q
- invalid ID %q
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/7e28921c63e29697.
Report an issue: GitHub.