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

Setting distinct_hosts to a boolean causes panic #489

Closed
F21 opened this issue Nov 23, 2015 · 2 comments
Closed

Setting distinct_hosts to a boolean causes panic #489

F21 opened this issue Nov 23, 2015 · 2 comments

Comments

@F21
Copy link

F21 commented Nov 23, 2015

The document states that the distinct_hosts attribute of the constraints object should be a boolean:

# Define a job called my-service
job "consul" {
    # Job should run in the US region
    region = "global"

    # Spread tasks between us-west-1 and us-east-1
    datacenters = ["dc1"]

    # run this job globally
    type = "system"

    # Rolling updates should be sequential
    update {
        stagger = "30s"
        max_parallel = 1
    }

    constraint{
        distinct_hosts = true
    }

    group "consul-server" {
        ...
    }
}

However, if I set it to true, nomad panics:

panic: interface conversion: interface is bool, not string

goroutine 1 [running]:
github.com/hashicorp/nomad/jobspec.parseConstraints(0xc82000cae8, 0xc8201975a0, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/nomad/jobspec/parse.go:321 +0x757
github.com/hashicorp/nomad/jobspec.parseJob(0xc82000ca80, 0xc8200f9080, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/nomad/jobspec/parse.go:118 +0x502
github.com/hashicorp/nomad/jobspec.Parse(0x7f1169afc270, 0xc820026220, 0xc820026220, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/nomad/jobspec/parse.go:53 +0x404
github.com/hashicorp/nomad/jobspec.ParseFile(0xc8200f8940, 0x1a, 0x0, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/nomad/jobspec/parse.go:73 +0x15c
github.com/hashicorp/nomad/command.(*RunCommand).Run(0xc8200f8900, 0xc82000a1b0, 0x1, 0x1, 0xc820106ea0)
        /opt/gopath/src/github.com/hashicorp/nomad/command/run.go:77 +0x28a
github.com/mitchellh/cli.(*CLI).Run(0xc8200b7c30, 0xc8200b7c30, 0x0, 0x0)
        /opt/gopath/src/github.com/mitchellh/cli/cli.go:112 +0x655
main.RunCustom(0xc82000a190, 0x3, 0x3, 0xc82015a390, 0x0)
        /opt/gopath/src/github.com/hashicorp/nomad/main.go:47 +0x469
main.Run(0xc82000a190, 0x3, 0x3, 0xfa48e8)
        /opt/gopath/src/github.com/hashicorp/nomad/main.go:15 +0x4c
main.main()
        /opt/gopath/src/github.com/hashicorp/nomad/main.go:11 +0x60

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1696 +0x1

goroutine 5 [syscall]:
os/signal.loop()
        /usr/local/go/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
        /usr/local/go/src/os/signal/signal_unix.go:28 +0x37

goroutine 8 [runnable]:
text/template/parse.lexText(0xc820083180, 0xf98208)
        /usr/local/go/src/text/template/parse/lex.go:237 +0x37e
text/template/parse.(*lexer).run(0xc820083180)
        /usr/local/go/src/text/template/parse/lex.go:206 +0x52
created by text/template/parse.lex
        /usr/local/go/src/text/template/parse/lex.go:199 +0x15d

goroutine 9 [runnable]:
github.com/hashicorp/nomad/command.(*Meta).FlagSet.func1(0xc820083280, 0xc8200f8900)
        /opt/gopath/src/github.com/hashicorp/nomad/command/meta.go:58
created by github.com/hashicorp/nomad/command.(*Meta).FlagSet
        /opt/gopath/src/github.com/hashicorp/nomad/command/meta.go:62 +0x3ce
@diptanu
Copy link
Contributor

diptanu commented Nov 23, 2015

@F21 It looks like we are assuming that the bool value true/false for this constraint is in quotes. so distinct_hosts="true" works.

cc/ @dadgar @cbednarski Thoughts about the UX? I think the value that we get from the hcl parser is of type interface{} It might be nice for us to not treat the value as a string. I can have a PR going for this.

benbuzbee pushed a commit to benbuzbee/nomad that referenced this issue Jul 21, 2022
Adds metrics suggested in hashicorp#488, to record the percentage of time the
main and FSM goroutines are busy with work vs available to accept new
work, to give operators an idea of how close they are to hitting
capacity limits.
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants