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

Nomad crashes parsing job definition #603

Closed
c4milo opened this issue Dec 18, 2015 · 4 comments
Closed

Nomad crashes parsing job definition #603

c4milo opened this issue Dec 18, 2015 · 4 comments

Comments

@c4milo
Copy link
Contributor

c4milo commented Dec 18, 2015

job "docker" {
    datacenters = ["iad2"]
    type = "service"
    priority = 1

    constraint {
        attribute = "$attr.kernel.name"
        value = "linux"
    }

    group "api" {
        count = 2
        restart {
            interval = "5m"
            attempts = 10
            delay = "25s"
        }

        task "registry" {
            driver = "docker"

            env {
                LOG_LEVEL="debug"
                REGISTRY_STORAGE="s3"
                REGISTRY_STORAGE_S3_ACCESSKEY=""
                REGISTRY_STORAGE_S3_SECRETKEY=""
                REGISTRY_STORAGE_S3_REGION="us-east-1"
                REGISTRY_STORAGE_S3_BUCKET="mybucket"
                REGISTRY_STORAGE_S3_ROOTDIRECTORY="/foo/bar/registry"
            }

            config {
                image = "registry:2"
                network_mode = "host"
            }

            service {
                name = "per-docker-registry"
                tags = ["global", "docker", "registry"]
                port = "http"
                check {
                    type = "http"
                    path = "/v2/"
                    interval = "10s"
                    timeout = "2s"
                }
            }

            resources {
                cpu = 1000 # Mhz
                memory = 1024 # MB
                network {
                    mbits = 100
                    port {
                        static = 5000
                    }
                }
            }
        }
    }
}
$ nomad run -address 192.168.50.4 registry.nomad
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/hashicorp/nomad/jobspec.parsePorts(0xc820114520, 0xc820189960, 0x0, 0x0)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/jobspec/parse.go:626 +0x87c
github.com/hashicorp/nomad/jobspec.parseResources(0xc820117c40, 0xc8201d2de0, 0x0, 0x0)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/jobspec/parse.go:612 +0x55e
github.com/hashicorp/nomad/jobspec.parseTasks(0xc820106271, 0x6, 0xc8201068d1, 0x3, 0xc820183958, 0xc8201cb0c0, 0x0, 0x0)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/jobspec/parse.go:477 +0x107b
github.com/hashicorp/nomad/jobspec.parseGroups(0xc8201c0000, 0xc820115e60, 0x0, 0x0)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/jobspec/parse.go:258 +0xcd0
github.com/hashicorp/nomad/jobspec.parseJob(0xc8201c0000, 0xc8201145c0, 0x0, 0x0)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/jobspec/parse.go:172 +0xde4
github.com/hashicorp/nomad/jobspec.Parse(0x55c0ec8, 0xc820112048, 0xc820112048, 0x0, 0x0)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/jobspec/parse.go:53 +0x404
github.com/hashicorp/nomad/jobspec.ParseFile(0xc820108320, 0x49, 0x0, 0x0, 0x0)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/jobspec/parse.go:73 +0x15c
github.com/hashicorp/nomad/command.(*RunCommand).Run(0xc8201140e0, 0xc82000a1d0, 0x1, 0x1, 0xc8201ac308)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/command/run.go:77 +0x28a
github.com/mitchellh/cli.(*CLI).Run(0xc8201b0000, 0xc8201b0000, 0x0, 0x0)
    /Users/c4milo/go/src/github.com/mitchellh/cli/cli.go:112 +0x698
main.RunCustom(0xc82000a1a0, 0x4, 0x4, 0xc820104600, 0x0)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/main.go:47 +0x469
main.Run(0xc82000a1a0, 0x4, 0x4, 0x4b22bc8)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/main.go:15 +0x4c
main.main()
    /Users/c4milo/go/src/github.com/hashicorp/nomad/main.go:11 +0x60

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

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

goroutine 18 [semacquire]:
sync.runtime_Syncsemacquire(0xc8201b2040)
    /usr/local/Cellar/go/1.5.2/libexec/src/runtime/sema.go:237 +0x201
sync.(*Cond).Wait(0xc8201b2030)
    /usr/local/Cellar/go/1.5.2/libexec/src/sync/cond.go:62 +0x9b
io.(*pipe).read(0xc8201b2000, 0xc8201b4000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.2/libexec/src/io/pipe.go:52 +0x2d2
io.(*PipeReader).Read(0xc820112038, 0xc8201b4000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.2/libexec/src/io/pipe.go:134 +0x50
bufio.(*Scanner).Scan(0xc820118100, 0x0)
    /usr/local/Cellar/go/1.5.2/libexec/src/bufio/scan.go:180 +0x877
github.com/hashicorp/nomad/command.(*Meta).FlagSet.func1(0xc820118100, 0xc8201140e0)
    /Users/c4milo/go/src/github.com/hashicorp/nomad/command/meta.go:59 +0x25
created by github.com/hashicorp/nomad/command.(*Meta).FlagSet
    /Users/c4milo/go/src/github.com/hashicorp/nomad/command/meta.go:62 +0x3ce

The issue is that I forgot to add the label "http" to the port block within the network resource

@diptanu
Copy link
Contributor

diptanu commented Dec 18, 2015

@c4milo We expect all ports to be named

So if you add a name to the port, the parsing should work

port "httpapi" {
     static = 5000
}

@diptanu
Copy link
Contributor

diptanu commented Dec 18, 2015

@c4milo Added a PR which would throw an error instead of Nomad crashing.

@c4milo
Copy link
Contributor Author

c4milo commented Dec 18, 2015

@diptanu, thanks for the really fast response. 👍

@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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants