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

Cannot set resources for sidecar tasks #7993

Closed
akhayyat opened this issue May 17, 2020 · 2 comments · Fixed by #8018
Closed

Cannot set resources for sidecar tasks #7993

akhayyat opened this issue May 17, 2020 · 2 comments · Fixed by #8018
Assignees
Labels
theme/consul/connect Consul Connect integration type/bug
Milestone

Comments

@akhayyat
Copy link

Nomad version

Nomad v0.11.1 (b434570)

Operating system and Environment details

Debian 10.3

Issue

When setting resource requirements for a Connect sidecar task using the service.connect.sidecar_task stanza, running the job results in the error:

Error submitting job: Put "https://localhost:4646/v1/jobs": EOF

The same job file without the sidecar_task.resources stanza runs fine.

Reproduction steps

Run a Docker job with some resource requirements defined under service.connect.sidecar_task.resources. See below for an example.

Job file (if appropriate)

job "echo" {
  datacenters = ["test"]
  group "echo" {
    network {
      mode = "bridge"
      port "http" {
        static = 8080
        to = 8080
      }
    }
    service {
      name = "echo"
      port = 8080
      connect {
        sidecar_service {}
        sidecar_task {
          resources {
            memory = 128
          }
        }
      }
    }
    task "echo" {
      user = 65534
      driver = "docker"
      config {
        image = "hashicorp/http-echo"
        args = [
          "-listen",
          ":8080",
          "-text",
          "hello world"
        ]
      }
      resources {
        memory = 10
      }
    }
  }
}

Nomad Client logs

2020-05-17T15:13:36.032Z [DEBUG] http: request complete: method=PUT path=/v1/jobs duration=267.105µs
2020-05-17T15:13:36.037Z [ERROR] http: http: panic serving [::1]:56382: runtime error: invalid memory address or nil pointer dereference
goroutine 56665 [running]:
net/http.(*conn).serve.func1(0xc000c18000)
        net/http/server.go:1772 +0x139
panic(0x2a07d20, 0x55da6a0)
        runtime/panic.go:973 +0x3e3
github.com/hashicorp/nomad/command/agent.ApiResourcesToStructs(0xc0004efe50, 0x0)
        github.com/hashicorp/nomad/command/agent/job_endpoint.go:1056 +0x60
github.com/hashicorp/nomad/command/agent.apiConnectSidecarTaskToStructs(0xc001961300, 0xc000c037a0)
        github.com/hashicorp/nomad/command/agent/job_endpoint.go:1269 +0x3c
github.com/hashicorp/nomad/command/agent.ApiConsulConnectToStructs(0xc0014f1080, 0xc000c18140)
        github.com/hashicorp/nomad/command/agent/job_endpoint.go:1192 +0x58
github.com/hashicorp/nomad/command/agent.ApiServicesToStructs(0xc0014f0fa0, 0x1, 0x4, 0xc0009426c8, 0x1, 0x1)
        github.com/hashicorp/nomad/command/agent/job_endpoint.go:1177 +0x1e1
github.com/hashicorp/nomad/command/agent.ApiTgToStructsTG(0xc000c565a0, 0xc001ade000, 0xc001ade0f0)
        github.com/hashicorp/nomad/command/agent/job_endpoint.go:783 +0x1cd
github.com/hashicorp/nomad/command/agent.ApiJobToStructJob(0xc001694840, 0x2759ce0)
        github.com/hashicorp/nomad/command/agent/job_endpoint.go:768 +0x4a7
github.com/hashicorp/nomad/command/agent.(*HTTPServer).jobUpdate(0xc000429090, 0x37b77c0, 0xc000687260, 0xc001d3fe00, 0x0, 0x0, 0x0, 0xc002027970, 0x8, 0xc002027930)  
        github.com/hashicorp/nomad/command/agent/job_endpoint.go:408 +0x1d8
github.com/hashicorp/nomad/command/agent.(*HTTPServer).JobsRequest(0xc000429090, 0x37b77c0, 0xc000687260, 0xc001d3fe00, 0x4d6f96, 0x5ec154a0, 0x1f0d59f, 0x368ac3774721)
        github.com/hashicorp/nomad/command/agent/job_endpoint.go:22 +0x84
github.com/hashicorp/nomad/command/agent.(*HTTPServer).wrap.func1(0x37b77c0, 0xc000687260, 0xc001d3fe00)
        github.com/hashicorp/nomad/command/agent/http.go:445 +0x176
net/http.HandlerFunc.ServeHTTP(0xc0004f6bc0, 0x37b77c0, 0xc000687260, 0xc001d3fe00)
        net/http/server.go:2012 +0x44
net/http.(*ServeMux).ServeHTTP(0xc0008ef4c0, 0x37b77c0, 0xc000687260, 0xc001d3fe00)
        net/http/server.go:2387 +0x1a5
github.com/hashicorp/nomad/vendor/github.com/NYTimes/gziphandler.GzipHandlerWithOpts.func1.1(0x37bb840, 0xc00159e0e0, 0xc001d3fe00)
        github.com/hashicorp/nomad/vendor/github.com/NYTimes/gziphandler/gzip.go:269 +0x1e6
net/http.HandlerFunc.ServeHTTP(0xc00092ec60, 0x37bb840, 0xc00159e0e0, 0xc001d3fe00)
        net/http/server.go:2012 +0x44
net/http.serverHandler.ServeHTTP(0xc0004d2620, 0x37bb840, 0xc00159e0e0, 0xc001d3fe00)
        net/http/server.go:2807 +0xa3
net/http.(*conn).serve(0xc000c18000, 0x37d28c0, 0xc001c03680)
        net/http/server.go:1895 +0x86c
created by net/http.(*Server).Serve
        net/http/server.go:2933 +0x35c
@shoenig
Copy link
Member

shoenig commented May 18, 2020

Thanks for reporting this @akhayyat ! There is definitely a bug here - if both (or neither) resources.memory and resources.cpu are set, everything is fine. However if only one is set, there is an attempt to derefence a nil pointer on the other.

@shoenig shoenig self-assigned this May 18, 2020
@shoenig shoenig added type/bug theme/consul/connect Consul Connect integration labels May 18, 2020
@shoenig shoenig added this to Needs Triage in Nomad - Community Issues Triage via automation May 18, 2020
@shoenig shoenig added this to the 0.11.3 milestone May 18, 2020
shoenig added a commit that referenced this issue May 19, 2020
Add `Canonicalize` methods to the connect components of a service
definition in the `nomad/structs` package. Without these, we have
been relying on complete or nonexistent input for connect stanza.

Fixes #7993
shoenig added a commit that referenced this issue May 19, 2020
Add `Canonicalize` methods to the connect components of a service
definition in the `api` package. Without these, we have been relying
on good input for the connect stanza.

Fixes #7993
shoenig added a commit that referenced this issue May 19, 2020
Add `Canonicalize` methods to the connect components of a service
definition in the `api` package. Without these, we have been relying
on good input for the connect stanza.

Fixes #7993
shoenig added a commit that referenced this issue May 19, 2020
Add `Canonicalize` methods to the connect components of a service
definition in the `api` package. Without these, we have been relying
on good input for the connect stanza.

Fixes #7993
Nomad - Community Issues Triage automation moved this from Needs Triage to Done May 26, 2020
@github-actions
Copy link

github-actions bot commented Nov 6, 2022

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 Nov 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
theme/consul/connect Consul Connect integration type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants