Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Error message from nomad-jobspec does not identify problem(s) with job template #1675

Closed
ragesoss opened this issue Jun 18, 2021 · 7 comments
Assignees
Labels
bug Something isn't working core
Milestone

Comments

@ragesoss
Copy link

Describe the bug
I'm trying out the new nomad-jobspec plugin as (perhaps) the blessed way to deploy a Nomad job, in place of what we've been doing. It doesn't work, but the error message doesn't give me a good idea of why.

Working version with this job template:

  deploy {
    use "exec" {
      command = ["nomad","run","<TPL>"]

      template {
        path = "${path.app}/job.hcl.tpl"
      }
    }
  }

Replacement version with nomad-jobspec:

  deploy {
    use "nomad-jobspec" {
      jobspec = templatefile("${path.app}/job.hcl.tpl")
    }
  }

The jobspec template appears to be incompatible with nomad-jobspec, but the error message didn't help me identify what that problem might be:

 2.7.1  ~/h/WikiEduDashboard   *$  waypoint deploy                                                                                                                                                                           Fri 18 Jun 2021 09:42:04 AM PDT

» Deploying...panic: runtime error: index out of range [1] with length 1

goroutine 68 [running]:
github.com/hashicorp/hcl/v2/hclsyntax.(*FunctionCallExpr).Value(0xc000aba2d0, 0xc000b7f530, 0xc00027dbf8, 0xc000d66523, 0x44ab060, 0xc000b30388, 0x469e53, 0x27dcac0, 0x16fa60)
        /home/circleci/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclsyntax/expression.go:463 +0x4f25
github.com/hashicorp/hcl/v2/gohcl.DecodeExpression(0x3205de8, 0xc000aba2d0, 0xc000b7f530, 0x276da60, 0xc000eb27b0, 0xc000eb27b0, 0x198, 0x27dcac0)
        /home/circleci/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/gohcl/decode.go:307 +0x59
github.com/hashicorp/hcl/v2/gohcl.decodeBodyToStruct(0x3205d40, 0xc000b71ad0, 0xc000b7f530, 0xc000eba120, 0xc000eb27b0, 0x199, 0x0, 0xc000e53410, 0x0)
        /home/circleci/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/gohcl/decode.go:124 +0x6ce
github.com/hashicorp/hcl/v2/gohcl.decodeBodyToValue(0x3205d40, 0xc000b71ad0, 0xc000b7f530, 0xc000eba120, 0xc000eb27b0, 0x199, 0xc000b30ba8, 0xf2e97d, 0xc000d743c0)
        /home/circleci/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/gohcl/decode.go:43 +0xd9
github.com/hashicorp/hcl/v2/gohcl.DecodeBody(0x3205d40, 0xc000b71ad0, 0xc000b7f530, 0xc000d749c0, 0xc000eb27b0, 0x1, 0xc000e53170, 0xc000e53200)
        /home/circleci/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/gohcl/decode.go:36 +0xf4
github.com/hashicorp/waypoint-plugin-sdk/component.Configure(0x2ba5180, 0xc000b71970, 0x3205d40, 0xc000b71ad0, 0xc000b7f530, 0xc00000fb58, 0x0, 0x1)
        /home/circleci/go/pkg/mod/github.com/hashicorp/[email protected]/component/configure.go:63 +0xe8
github.com/hashicorp/waypoint/internal/config.(*Operation).Configure(0xc00097d900, 0x2ba5180, 0xc000b71970, 0xc000b7e648, 0xc000e527e0, 0x101, 0xd)
        /home/circleci/project/waypoint/internal/config/operation.go:29 +0x270
github.com/hashicorp/waypoint/internal/core.(*componentCreator).create(0xc0002419e0, 0x3205758, 0xc00005a0d0, 0xc00033e3c0, 0x2d6851be84cba901, 0xc000b7e648, 0x0, 0x0, 0xc000e14340)
        /home/circleci/project/waypoint/internal/core/component_creator.go:187 +0x385
github.com/hashicorp/waypoint/internal/core.(*componentCreator).Create(...)
        /home/circleci/project/waypoint/internal/core/component_creator.go:112
github.com/hashicorp/waypoint/internal/core.(*deployOperation).reinitComponent(0xc0000c9bd0, 0xc00033e3c0, 0x9, 0x2d1b2ec)
        /home/circleci/project/waypoint/internal/core/app_deploy.go:176 +0x587
github.com/hashicorp/waypoint/internal/core.(*deployOperation).Init(0xc0000c9bd0, 0xc00033e3c0, 0x100000000000000, 0x7f0493ce5ed0, 0x0, 0x26)
        /home/circleci/project/waypoint/internal/core/app_deploy.go:187 +0x50
github.com/hashicorp/waypoint/internal/core.(*App).doOperation(0xc00033e3c0, 0x3205720, 0xc000024640, 0x3237c78, 0xc0001fb500, 0x321c938, 0xc0000c9bd0, 0x0, 0x0, 0x0, ...)
        /home/circleci/project/waypoint/internal/core/operation.go:60 +0x88
github.com/hashicorp/waypoint/internal/core.(*App).Deploy(0xc00033e3c0, 0x3205720, 0xc000024640, 0xc000a729a0, 0x0, 0x0, 0x0)
        /home/circleci/project/waypoint/internal/core/app_deploy.go:45 +0x27b
github.com/hashicorp/waypoint/internal/runner.(*Runner).executeDeployOp(0xc00059ca90, 0x3205720, 0xc000024640, 0xc00025b100, 0xc0001d2cc0, 0x0, 0x0, 0x0)
        /home/circleci/project/waypoint/internal/runner/operation_deploy.go:27 +0xbd
github.com/hashicorp/waypoint/internal/runner.(*Runner).executeJob(0xc00059ca90, 0x3205720, 0xc000024640, 0x3237c78, 0xc0007e3e30, 0x3220da8, 0xc0009d9878, 0xc00025b100, 0xc0000560c4, 0x31, ...)
        /home/circleci/project/waypoint/internal/runner/operation.go:173 +0x12e6
github.com/hashicorp/waypoint/internal/runner.(*Runner).prepareAndExecuteJob(0xc00059ca90, 0x3205720, 0xc000024640, 0x3237c78, 0xc0007e3e30, 0x3220da8, 0xc0009d9878, 0xc0007dad80, 0x3221118, 0xc000b6af50, ...)
        /home/circleci/project/waypoint/internal/runner/accept.go:407 +0x507
github.com/hashicorp/waypoint/internal/runner.(*Runner).accept(0xc00059ca90, 0x3205720, 0xc000024640, 0x0, 0x0, 0x0, 0x0)
        /home/circleci/project/waypoint/internal/runner/accept.go:276 +0xd7f
github.com/hashicorp/waypoint/internal/runner.(*Runner).Accept(...)
        /home/circleci/project/waypoint/internal/runner/accept.go:75
github.com/hashicorp/waypoint/internal/runner.(*Runner).AcceptMany(0xc00059ca90, 0x3205720, 0xc0000b9f00)
        /home/circleci/project/waypoint/internal/runner/accept.go:26 +0x4b
github.com/hashicorp/waypoint/internal/client.New.func1(0xc0007e5b80, 0xc00059ca90)
        /home/circleci/project/waypoint/internal/client/project.go:108 +0x72
created by github.com/hashicorp/waypoint/internal/client.New
        /home/circleci/project/waypoint/internal/client/project.go:106 +0x37e

Expected behavior
If there's a problem with the jobspec template, I expect an error message that gives a clear indication of the problem in terms of the .hcl or .tpl files involved.

Waypoint Platform Versions

  • Waypoint CLI Version: 0.4.0
  • Waypoint Server Platform and Version: 0.4.0, nomad
  • Waypoint Plugin: nomad-jobspec
@ragesoss ragesoss added the new label Jun 18, 2021
@mitchellh mitchellh added bug Something isn't working core labels Jun 18, 2021
@mitchellh mitchellh added this to the 0.4.x milestone Jun 18, 2021
@mitchellh mitchellh removed the new label Jun 18, 2021
@mitchellh
Copy link
Contributor

I think I saw this in development and I think its an HCL bug where its failing to notify an unavailable var error. We'll get this fixed!

@mitchellh
Copy link
Contributor

I'm chasing down the HCL bug, but that is just masking the real issue here which is that templatefile uses the HCL templating format and Nomad itself is an HCL file. So when templating, we're evaluating all the functions and variables that Nomad exposes (which we obviously don't).

Escaping everything is kind of painful in Nomad so I'm thinking 🤔 about how we should make the ergonomics around this a lot less painful.

@briancain
Copy link
Member

Hey there @ragesoss - thanks for opening an issue with Waypoint! It looks like the error you mentioned is now fixed in a recent release of Waypoint. We had another request for supporting input variables with Nomad here: #1979. Since the error is fixed, I'm going to go ahead and close this issue. It looks like the solution proposed on that issue should accomplish what you are trying to do with your Waypoint and Nomad setup. If you have any more additional context that you'd like to share, please feel free to include it on the issue! Thanks again ✨

@ragesoss
Copy link
Author

@briancain thanks! I'm getting a better error message now, but I'm still stuck with moving from exec to nomad-jobspec.

Now it says:

  Invalid function argument; Invalid value for "template_path" parameter: template
  refers to variable "node" at
  /home/sage/hashistack_deployment/dashboard_TESTING/job.hcl.tpl:92,22-26, but
  this call has no vars map., and 1 other diagnostic(s)

I couldn't find any details or examples on how to access node attributes from within the jobspec template when using the nomad-jobspec plugin.

@siccous
Copy link

siccous commented Jan 19, 2022

Hit this today too, same problem as @ragesoss

Did you find any solution?

@ragesoss
Copy link
Author

@siccous no, I'm still using exec instead of nomad-jobspec.

@siccous
Copy link

siccous commented Jan 20, 2022

@siccous no, I'm still using exec instead of nomad-jobspec.

For me double $ works as escaping:

"$${node.unique.name}"

At least it seems to work and I successfully migrated to Nomad jobspec.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working core
Projects
None yet
Development

No branches or pull requests

4 participants