-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Templating to shared alloc/ directory #9610
Comments
There's almost certainly opportunity for better docs here; this often results in a lot of trial and error to figure out these relative paths. However, I did have success with the following approach, which relies strictly on interpolation: job "repro" {
datacenters = ["dc1"]
type = "batch"
group "repro" {
task "a" {
driver = "exec"
config {
command = "cat"
args = ["${NOMAD_ALLOC_DIR}/shared.txt"]
}
template {
destination = "${NOMAD_ALLOC_DIR}/shared.txt"
data = <<EOH
Hello, world!
EOH
}
}
task "b" {
driver = "exec"
config {
command = "cat"
args = ["${NOMAD_ALLOC_DIR}/shared.txt"]
}
}
}
} |
Hah, interesting... it does work fine with the
|
@valenvb , I've marked this as a bug, because it really seems like this behavior is subverting the intended workflow. I haven't finished investigating, but it looks like this works for We'll need to come up with some change so that we can honor this use case. In the short term, a workaround may be to render the file to the alloc in a job "workaround" {
datacenters = ["dc1"]
type = "batch"
group "repro" {
task "init" {
lifecycle {
hook = "prestart"
}
template {
destination = "local/shared.txt"
data = <<EOH
Hello, world!
EOH
}
driver = "docker"
config {
image = "alpine:3"
command = "cp"
args = ["${NOMAD_TASK_DIR}/shared.txt", "${NOMAD_ALLOC_DIR}/shared.txt"]
}
}
task "a" {
driver = "docker"
config {
image = "alpine:3"
command = "cat"
args = ["${NOMAD_ALLOC_DIR}/shared.txt"]
}
}
task "b" {
driver = "docker"
config {
image = "alpine:3"
command = "cat"
args = ["${NOMAD_ALLOC_DIR}/shared.txt"]
}
}
}
} |
Thanks for looking into this @cgbaker. I'll see if I can make the prestart job work in my use case - unfortunately the first job that needs the templated file is a prestart job already.. So far it seems like the tasks are run in the order defined by the jobfile, but I haven't seen that made explicit anywhere |
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. |
Nomad version
Nomad v1.0.0 (cfca6405ad9b5f66dffc8843e3d16f92f3bedb43)
Issue
This seems to be a bug specifically with the
docker
driver.I need to template a file in the group shared
alloc/data/
directory, such that all tasks in the group can read it.The docs for
template
indicate thatdestination
is relative to the task working directory, and links to this page. This implies that I should be able to set thedestination
toalloc/data/file
. However this results in analloc/
directory created next to the taskslocal/
directory, inside the task-only working directory.ie:
/var/nomad/alloc/<alloc_id>
looks likewhen what I would expect to see is
in Nomad
0.12.4
I was able to circumvent this by using a destination of../alloc/data/file
, however this is considered an alloc directory escape now, resulting in the error:destination path escapes the alloc directory
Reproduction steps
Run a job file as below
Job file (if appropriate)
The text was updated successfully, but these errors were encountered: