hashicorp / hashicorp/nomad

[Feature Request] Property to set prestart task to run only one instance even if in larger group

Open
#8,067 7 comments 11 reactions 0 assignees View on GitHub
theme/scheduling type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

It would be great to be able to set a property for a prestart task to run only as a single instance even if the task group has a count larger than 1.

The use case for this is that we are using prestart tasks to populate Vault secrets, and if the group has a count larger than 1 then the prestart task will also be executed multiple times, resulting in multiple versions of the same secrets being updated in the vault secret kv in our case.

So something like the below is what I'm proposing, I redacted all other job stanzas to keep the example clear. The lifecycle "mode" property could consist of options "single" and "group" to begin with, defaulting to "group", meaning it will start up as many instances as the group count declares.

```
group "example" {
count = 3

task "prestart" {
lifecycle {
hook = "prestart"
mode = "single"
}

driver = "docker"

config {
image = "alpine:3.11"
entrypoint = ["myPrestart.sh"]
}
}

task "main" {
driver = "docker"

config {
image = "myImage"
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing Nomad's prestart lifecycle and how task-group counts launch hook tasks. Define and test the proposed single-versus-group behavior, including the default, with completion shown by a prestart task running once when the group count is three.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.