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

HCL: CLI panics when parsing invalid connect.gateway.proxy.port #10072

Closed
tgross opened this issue Feb 23, 2021 · 1 comment · Fixed by #10075
Closed

HCL: CLI panics when parsing invalid connect.gateway.proxy.port #10072

tgross opened this issue Feb 23, 2021 · 1 comment · Fixed by #10075

Comments

@tgross
Copy link
Member

tgross commented Feb 23, 2021

Discovered while doing some testing of #9851. In the jobspec below, the connect.gateway.proxy.port should be an integer, not a string. But the CLI panics when you attempt to validate this jobspec.

jobspec
job "example" {
  datacenters = ["dc1"]

  group "ingress-group" {

    network {
      mode = "bridge"
      port "inbound" {
        static = 8081
        to     = 8080
      }
    }

    service {
      name = "my-ingress-service"
      port = "8080"

      connect {
        gateway {
          proxy {
            envoy_gateway_no_default_bind = true
            envoy_gateway_bind_addresses "uuid-api" {
              address = "0.0.0.0"
              port    = "inbound" # <-- this causes the NPE
            }
          }

          ingress {
            listener {
              port     = 8080
              protocol = "tcp"
              service {
                name = "uuid-api"
              }
            }
          }
        }
      }
    }
  }

  group "generator" {
    network {
      mode = "host"
      port "api" {}
    }

    service {
      name = "uuid-api"
      port = "${NOMAD_PORT_api}"

      connect {
        native = true
      }
    }

    task "generate" {
      driver = "docker"

      config {
        image        = "hashicorpnomad/uuid-api:v3"
        network_mode = "host"
      }

      env {
        BIND = "0.0.0.0"
        PORT = "${NOMAD_PORT_api}"
      }
    }
  }
}
$ nomad job run ../../example.nomad
panic: strconv.ParseInt: parsing "inbound": invalid syntax

goroutine 1 [running]:
github.com/hashicorp/nomad/jobspec.parseGatewayProxy(0xc0003136e0, 0xc00061eda0, 0x1, 0x1)
        github.com/hashicorp/nomad/jobspec/parse_service.go:349 +0xb45
github.com/hashicorp/nomad/jobspec.parseGateway(0xc0003135c0, 0xc00061ee50, 0x1, 0x1)
        github.com/hashicorp/nomad/jobspec/parse_service.go:267 +0x374
github.com/hashicorp/nomad/jobspec.parseConnect(0xc0003134a0, 0xc00061ef70, 0x1, 0x1)
        github.com/hashicorp/nomad/jobspec/parse_service.go:183 +0x699
github.com/hashicorp/nomad/jobspec.parseService(0xc000313380, 0x1, 0x1, 0xc000198ec8)
        github.com/hashicorp/nomad/jobspec/parse_service.go:106 +0x585
github.com/hashicorp/nomad/jobspec.parseGroupServices(0xc0002ec690, 0xc00033f1a0, 0x1, 0x1)
        github.com/hashicorp/nomad/jobspec/parse_service.go:16 +0xc6
github.com/hashicorp/nomad/jobspec.parseGroups(0xc00019c900, 0xc00033e700, 0x1, 0x1)
        github.com/hashicorp/nomad/jobspec/parse_group.go:220 +0xeb8
github.com/hashicorp/nomad/jobspec.parseJob(0xc00019c900, 0xc000190960, 0x1, 0x1)
        github.com/hashicorp/nomad/jobspec/parse_job.go:186 +0xc6f
github.com/hashicorp/nomad/jobspec.Parse(0x7102f40, 0xc0004ea720, 0x71033c0, 0xc000417fe0, 0x0)
        github.com/hashicorp/nomad/jobspec/parse.go:61 +0x30e
github.com/hashicorp/nomad/command.(*JobGetter).ApiJobWithArgs(0xc0000e2e80, 0x7ffeefbff896, 0x13, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/nomad/command/helpers.go:465 +0x47a
github.com/hashicorp/nomad/command.(*JobRunCommand).Run(0xc0000e2dd0, 0xc0001a2030, 0x1, 0x1, 0xc000115510)
        github.com/hashicorp/nomad/command/job_run.go:197 +0x6ef
github.com/mitchellh/cli.(*CLI).Run(0xc00037a000, 0xc00037a000, 0xc000810000, 0x3b)
        github.com/mitchellh/[email protected]/cli.go:260 +0x1cf
main.RunCustom(0xc0001a2010, 0x3, 0x3, 0xc0000b0058)
        github.com/hashicorp/nomad/main.go:142 +0x4a5
main.Run(...)
        github.com/hashicorp/nomad/main.go:87
main.main()
        github.com/hashicorp/nomad/main.go:83 +0x65
@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 Oct 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant