hashicorp / hashicorp/nomad

Cannot use variables/interpolation with configurations expecting integers

Open
#5,531 15 comments 2 reactions 0 assignees View on GitHub
stage/needs-discussion theme/hcl theme/jobspec
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version
`Nomad v0.8.7 (21a2d93eecf018ad2209a5eab6aae6c359267933+CHANGES)`

### Operating system and Environment details
Gentoo Linux + Docker 18.09.2

### Issue

Cannot use variables/interpolation with configurations expecting integers.

I'm configuring a docker job to populate the `shm_size` config which expects an integer.

If submit the interpolation with surrounding quotes `"${NOMAD_META_SHM_SIZE}"`,

I get

```
* field "shm_size" with input "${NOMAD_META_SHM_SIZE}" doesn't seem to be of type integer
* group "cluster" -> task "runme" -> config: 1 error(s) occurred:
```

If I submit the interpolation without surrounding quotes `${NOMAD_META_SHM_SIZE}`

I get a syntax error

eg.
```
Error getting job struct: Error parsing job file from job.nomad: error parsing: At 24:20: illegal char
```

In terraform, this interpolated change of type seems to be handled internally, but here it seems a hard requirement of the `shm_size` configuration.

### Job file (if appropriate)

```
job "stuff" {
type = "service"
datacenters = ["dc1"]
meta {
SHM_SIZE = 2000000000
}
group "cluster" {
task "runme" {
driver = "docker"
config {
shm_size = "${NOMAD_META_SHM_SIZE}"
image = "image"
}
}
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the supplied job file with shm_size set through NOMAD_META_SHM_SIZE, comparing quoted and unquoted interpolation. Trace Nomad's job-file parsing and Docker configuration validation to identify where integer interpolation is rejected; done means the integer-valued interpolation is accepted without a syntax or type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.