Skip to content

Commit

Permalink
Merge pull request #3136 from hashicorp/b-distinct-host
Browse files Browse the repository at this point in the history
Allow distinct_host to have L/RTarget set
  • Loading branch information
dadgar committed Aug 30, 2017
2 parents aa9bb33 + 84c8651 commit d1e2950
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ BUG FIXES:
another job [GH-3120]
* cli: Fix setting of TLSServerName for node API Client. This fixes an issue of
contacting nodes that are using TLS [GH-3127]
* jobspec: Allow distinct_host constraint to have L/RTarget set [GH-3136]

## 0.6.2 (August 28, 2017)

Expand Down
6 changes: 0 additions & 6 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3973,12 +3973,6 @@ func (c *Constraint) Validate() error {
switch c.Operand {
case ConstraintDistinctHosts:
requireLtarget = false
if c.RTarget != "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Distinct hosts constraint doesn't allow RTarget. Got %q", c.RTarget))
}
if c.LTarget != "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Distinct hosts constraint doesn't allow LTarget. Got %q", c.LTarget))
}
case ConstraintSetContains:
if c.RTarget == "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Set contains constraint requires an RTarget"))
Expand Down
12 changes: 4 additions & 8 deletions nomad/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,14 +1353,10 @@ func TestConstraint_Validate(t *testing.T) {

// Perform distinct_hosts validation
c.Operand = ConstraintDistinctHosts
c.RTarget = "foo"
err = c.Validate()
mErr = err.(*multierror.Error)
if !strings.Contains(mErr.Errors[0].Error(), "doesn't allow RTarget") {
t.Fatalf("err: %s", err)
}
if !strings.Contains(mErr.Errors[1].Error(), "doesn't allow LTarget") {
t.Fatalf("err: %s", err)
c.LTarget = ""
c.RTarget = ""
if err := c.Validate(); err != nil {
t.Fatalf("expected valid constraint: %v", err)
}

// Perform set_contains validation
Expand Down

0 comments on commit d1e2950

Please sign in to comment.