Distinct Property supports arbitrary limit

This PR enhances the distinct_property constraint such that a limit can
be specified in the RTarget/value parameter. This allows constraints
such as:

```
constraint {
  distinct_property = "${meta.rack}"
  value = "2"
}
```

This restricts any given rack from running more than 2 allocations from
the task group.

Fixes https://github.com/hashicorp/nomad/issues/1146
This commit is contained in:
Alex Dadgar
2017-07-31 16:44:17 -07:00
parent abdb7c3297
commit 4e71ba2e71
8 changed files with 506 additions and 66 deletions

View File

@@ -76,6 +76,20 @@ func IntMin(a, b int) int {
return b
}
func IntMax(a, b int) int {
if a > b {
return a
}
return b
}
func Uint64Max(a, b uint64) uint64 {
if a > b {
return a
}
return b
}
// MapStringStringSliceValueSet returns the set of values in a map[string][]string
func MapStringStringSliceValueSet(m map[string][]string) []string {
set := make(map[string]struct{})