Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow distinct_host to have L/RTarget set #3136

Merged
merged 2 commits into from
Aug 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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