Skip to content

Commit d1e2950

Browse files
authored
Merge pull request #3136 from hashicorp/b-distinct-host
Allow distinct_host to have L/RTarget set
2 parents aa9bb33 + 84c8651 commit d1e2950

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ BUG FIXES:
88
another job [GH-3120]
99
* cli: Fix setting of TLSServerName for node API Client. This fixes an issue of
1010
contacting nodes that are using TLS [GH-3127]
11+
* jobspec: Allow distinct_host constraint to have L/RTarget set [GH-3136]
1112

1213
## 0.6.2 (August 28, 2017)
1314

nomad/structs/structs.go

-6
Original file line numberDiff line numberDiff line change
@@ -3973,12 +3973,6 @@ func (c *Constraint) Validate() error {
39733973
switch c.Operand {
39743974
case ConstraintDistinctHosts:
39753975
requireLtarget = false
3976-
if c.RTarget != "" {
3977-
mErr.Errors = append(mErr.Errors, fmt.Errorf("Distinct hosts constraint doesn't allow RTarget. Got %q", c.RTarget))
3978-
}
3979-
if c.LTarget != "" {
3980-
mErr.Errors = append(mErr.Errors, fmt.Errorf("Distinct hosts constraint doesn't allow LTarget. Got %q", c.LTarget))
3981-
}
39823976
case ConstraintSetContains:
39833977
if c.RTarget == "" {
39843978
mErr.Errors = append(mErr.Errors, fmt.Errorf("Set contains constraint requires an RTarget"))

nomad/structs/structs_test.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -1353,14 +1353,10 @@ func TestConstraint_Validate(t *testing.T) {
13531353

13541354
// Perform distinct_hosts validation
13551355
c.Operand = ConstraintDistinctHosts
1356-
c.RTarget = "foo"
1357-
err = c.Validate()
1358-
mErr = err.(*multierror.Error)
1359-
if !strings.Contains(mErr.Errors[0].Error(), "doesn't allow RTarget") {
1360-
t.Fatalf("err: %s", err)
1361-
}
1362-
if !strings.Contains(mErr.Errors[1].Error(), "doesn't allow LTarget") {
1363-
t.Fatalf("err: %s", err)
1356+
c.LTarget = ""
1357+
c.RTarget = ""
1358+
if err := c.Validate(); err != nil {
1359+
t.Fatalf("expected valid constraint: %v", err)
13641360
}
13651361

13661362
// Perform set_contains validation

0 commit comments

Comments
 (0)