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

Target parsing panics when name is not set #71

Closed
lgfa29 opened this issue Apr 1, 2020 · 0 comments · Fixed by #114
Closed

Target parsing panics when name is not set #71

lgfa29 opened this issue Apr 1, 2020 · 0 comments · Fixed by #114
Assignees
Milestone

Comments

@lgfa29
Copy link
Contributor

lgfa29 commented Apr 1, 2020

If name is not set in the target block of a policy the agent will panic.

Log output

2020-04-01T13:16:02.456-0400 [INFO]  agent: reading policies: policy_storage=policystorage.Nomad
2020-04-01T13:16:02.458-0400 [INFO]  agent: found 1 policies: policy_storage=policystorage.Nomad
panic: interface conversion: interface {} is nil, not string

goroutine 131 [running]:
github.com/hashicorp/nomad-autoscaler/policystorage.parseTarget(0x17000a0, 0xc0004626c0, 0x183ae3d)
        /Users/laoqui/go/src/github.com/hashicorp/nomad-autoscaler/policystorage/nomad.go:143 +0x3d8
github.com/hashicorp/nomad-autoscaler/policystorage.(*Nomad).Get(0xc00000e028, 0xc000375da0, 0x24, 0x2, 0x1, 0x13c4d00)
        /Users/laoqui/go/src/github.com/hashicorp/nomad-autoscaler/policystorage/nomad.go:53 +0x266
github.com/hashicorp/nomad-autoscaler/agent.(*Agent).Run.func1(0xc00014c040, 0x1984400, 0xc0001508c0, 0xc00000e028, 0x198ff60, 0xc0003c6a50, 0xc00021a2d0, 0xc000375da0, 0x24)
        /Users/laoqui/go/src/github.com/hashicorp/nomad-autoscaler/agent/agent.go:107 +0xc3
created by github.com/hashicorp/nomad-autoscaler/agent.(*Agent).Run
        /Users/laoqui/go/src/github.com/hashicorp/nomad-autoscaler/agent/agent.go:101 +0x60f

Sample policy

policy {
  source = "prometheus"
  query  = "scalar(avg((haproxy_server_current_sessions{backend=\"http_back\"}) and (haproxy_server_up{backend=\"http_back\"} == 1)))"

  strategy = {
    name = "target-value"

    config = {
      target = 20
    }
  }

  target {
    config {
      dry-run = "true"
    }
  }
}

Expected behaviour:

Target defaults to local Nomad cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants