asteris-llc / converge

A powerful and easy-to-use configuration management system.
Apache License 2.0
250 stars 31 forks source link

Node is sometimes unresolvable, depending on ordering within a template #254

Closed rebeccaskinner closed 8 years ago

rebeccaskinner commented 8 years ago

This is broken...

task.query "should-install-go" {
  interpreter = "/bin/bash"
  query = "[[ '{{param `goversion`}}' == '{{lookup `task.query.go-installed-version.checkstatus.stdout`}}']]"
}

but this isnt...

task.query "should-install-go" {
  interpreter = "/bin/bash"
  query = "[[ '{{lookup `task.query.go-installed-version.checkstatus.stdout`}}' == '{{param `goversion`}}' ]]"
}

in

task.query "lookup-gopath" {
  interpreter = "/bin/bash"
  query = " if [[ -z $GOPATH ]]; then echo -n '{{param `defaultGopath`}}'; else echo -n ${GOPATH}; fi "
}

task.query "go-installed-version" {
  interpreter = "/bin/bash"
  query = "go version | awk '{print $3}'"
}

param "goversion" {
  default = "1.7.1"
}

task.query "should-install-go" {
  interpreter = "/bin/bash"
  query = "[[ '{{lookup `task.query.go-installed-version.checkstatus.stdout`}}' == '{{param `goversion`}}' ]]"
}

param "defaultGopath" {
  default = "${HOME}/go"
}

param "gopath" {
  default = "{{lookup `task.query.lookup-gopath.status.stdout`}}"
}

param "platform" {
  default = "darwin-amd64"
}

param "gopkg" {
  default = "https://storage.googleapis.com/golang/{{param `packagename`}}"
}

param "packagename" {
  default = "go{{param `goversion`}}.{{param `platform`}}.pkg"
}

task.query "tempdir" {
  interpreter = "/bin/bash"
  query = "echo -n $(mktemp -d)"
}

param "downloadpath" {
  default = "{{lookup `task.query.tempdir.Status.Stdout`}}/{{param `packagename`}}"
}

task "download go" {
  interpreter = "/bin/bash"
  check = "[[ 1 == {{lookup `task.query.should-install-go.status.exitstatus`}} && -f {{param `downloadpath`}} ]]"
  apply = "curl {{param `gopkg`}} > {{param `downloadpath`}}"
}
BrianHicks commented 8 years ago

what's the error?

rebeccaskinner commented 8 years ago

Minimal reproduction:

param "bar" {
  default = "bar"
}
task.query "foo" {
  query = "echo foo"
}
task.query "should-install-go" {
  interpreter = "/bin/bash"
  query = "[[ '{{param `bar`}}' == '{{lookup `task.query.foo.checkstatus.stdout`}}']]"

  ## works this way
  # query = "[['{{lookup `task.query.foo.checkstatus.stdout`}}' ==  '{{param `bar`}}']]"
}

Output:

timestamp="2016-09-19T08:06:47-05:00" level="WARN" msg="setting session-local token" token="91dc0074-bdfa-43b0-b0aa-bef4636378ff"
timestamp="2016-09-19T08:06:47-05:00" level="INFO" msg="serving" addr=":47740" component="rpc"
timestamp="2016-09-19T08:06:47-05:00" level="WARN" msg="skipping module verfiction" component="client"
timestamp="2016-09-19T08:06:47-05:00" level="INFO" msg="planning" component="client" file="bad.hcl"
timestamp="2016-09-19T08:06:47-05:00" level="INFO" msg="resolving dependencies" component="rpc" function="ResolveDependencies" runID="b3d10f39-ddb7-4bee-891b-c894f51be966"
timestamp="2016-09-19T08:06:47-05:00" level="INFO" msg="loading resources" component="rpc" function="SetResources" runID="b3d10f39-ddb7-4bee-891b-c894f51be966"
timestamp="2016-09-19T08:06:47-05:00" level="INFO" msg="no check_flags specified for interpeter, skipping syntax validation" 
timestamp="2016-09-19T08:06:47-05:00" level="INFO" msg="got status" component="client" file="bad.hcl" id="root/param.bar" run="STARTED" stage="PLAN"
timestamp="2016-09-19T08:06:47-05:00" level="INFO" msg="got status" component="client" file="bad.hcl" id="root/task.query.foo" run="STARTED" stage="PLAN"
timestamp="2016-09-19T08:06:47-05:00" level="INFO" msg="got status" component="client" file="bad.hcl" id="root/task.query.should-install-go" run="STARTED" stage="PLAN"
pipeline returned Right node is unresolvable
timestamp="2016-09-19T08:06:47-05:00" level="ERROR" msg="planning failed" component="rpc" error="1 error(s) occurred:\n\n* root/task.query.should-install-go: node is unresolvable" function="executor.Plan" location="bad.hcl" runID="b3d10f39-ddb7-4bee-891b-c894f51be966"
timestamp="2016-09-19T08:06:47-05:00" level="FATAL" msg="could not get responses" component="client" error="error getting status response: rpc error: code = 2 desc = planning bad.hcl: 1 error(s) occurred:\n\n* root/task.query.should-install-go: node is unresolvable" file="bad.hcl"
rebeccaskinner commented 8 years ago

Fixed in #265

rebeccaskinner commented 8 years ago

Fixed in #288