Distinct host for batch jobs

Hi,
I’m currently trying to run parameterized batch jobs on Nomad where I want to set the constraint:

constraint {
  distinct_host = true
}

But as nomad creates a new child job this contraint doesn’t have any effect it seem as the child job see only it self therefore always beeing distinct.

Is there anyway to do something like this?

Hi, a trick, take a unique port number and assign it to the job. Nomad will register that port is used, and only schedule new jobs on hosts where the port is free, effectively doing distinct hosts.

1 Like

Thanks, it seems to kind of work when I use

network {
 port "some_name" {
   static = 20000
 }
}

But for some reason I can still run 3 allocations (with the 4th I see the placement error) with that when I try it with a single host dev agent.