hashicorp/nomad · error

Sum of spread target percentages must not be greater than 10

Error message

Sum of spread target percentages must not be greater than 100%%; got %d%%

What it means

Spread.Validate() sums all SpreadTarget percentages and rejects the job if the total exceeds 100 with 'Sum of spread target percentages must not be greater than 100%; got %d%%'. Remaining capacity (100 - sum) is implicitly spread evenly across non-targeted nodes.

Source

Thrown at nomad/structs/structs.go:10348

	}
	seen := make(map[string]struct{})
	sumPercent := uint32(0)

	for _, target := range s.SpreadTarget {
		// Make sure there are no duplicates
		_, ok := seen[target.Value]
		if !ok {
			seen[target.Value] = struct{}{}
		} else {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("Spread target value %q already defined", target.Value))
		}
		if target.Percent > 100 {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("Spread target percentage for value %q must be between 0 and 100", target.Value))
		}
		sumPercent += uint32(target.Percent)
	}
	if sumPercent > 100 {
		mErr.Errors = append(mErr.Errors, fmt.Errorf("Sum of spread target percentages must not be greater than 100%%; got %d%%", sumPercent))
	}
	return mErr.ErrorOrNil()
}

// SpreadTarget is used to specify desired percentages for each attribute value
type SpreadTarget struct {
	// Value is a single attribute value, like "dc1"
	Value string

	// Percent is the desired percentage of allocs
	Percent uint8

	// Memoized string representation
	str string
}

func (s *SpreadTarget) Copy() *SpreadTarget {
	if s == nil {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Reduce target percentages so their total is <= 100.
  2. Leave some percentage unallocated to allow spreading across other nodes.
  3. Normalize the targets programmatically (scale each by 100/sum) before rendering.

Example fix

// before
spread {
  attribute = "${node.datacenter}"
  target "dc1" { percent = 60 }
  target "dc2" { percent = 60 }
}
// after
spread {
  attribute = "${node.datacenter}"
  target "dc1" { percent = 50 }
  target "dc2" { percent = 50 }
}
Defensive patterns

Strategy: validation

Validate before calling

sum := uint32(0)
for _, t := range spread.SpreadTarget { sum += t.Percent }
if sum > 100 { return fmt.Errorf("spread percentages sum to %d > 100", sum) }

Prevention

When it happens

Trigger: Registering a job where the spread targets sum to more than 100, e.g. dc1=60 and dc2=60 (sum 120), at job submission.

Common situations: Adding a new target without rebalancing existing ones, treating the sum as independent per-target budgets, or scripts that scale percentages incorrectly.

Related errors


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