Constraint attribute based on jobs?

Hi
We have a service which runs a heavy lifting import job at a certain time (scheduler) and we run this service mutliple times in different namespaces (different job files, different configs).

Due to the nature of binpack, it is often the case 2 of them run on the same node. Which may cause pressure on the node if they run in parallel.

Is there a way to define a contraint: run this job on any node except already have a job “kind like this”?

Hi @resmo

Thanks for using Nomad!

There isn’t a native way of doing this at this time. This issue is where the feature request is being discussed.

One option available to you today is to define a pre-start lifecycle hook that checks for jobs with some metadata that you define, and have the task sleep until the query returns no jobs with that metadata. Here’s an example from the Nomad Pack Project where we inspect metadata for running jobs.

If this is a blocking issue for you right now, you could always write a little handler yourself that handles this business logic and blocks the task until no other similar jobs are running. You might even be able to pull this off with curl and jq. The gist of the logic would be

  • Get all jobs for node
  • Iterate through jobs looking to see if any are the kind you care about
  • Implement the init task pattern in your lifecycle hook to block until node is ready

I hope that helps!

  • Derek

thanks @DerekStrickland and thank you for Nomad (and keep working on it)!

Imho the feature request covers our use case as well.

Except that our job is a “service” but that shouldn’t make any difference, right? It is not a critical issue, I just wondered if it would be possible.

Cheers.
René

It should not make a difference. What would be really helpful is if you added your upvote/thoughts/request/requirements to that issue, so that it gets incorporated into the discussion.

Thanks!

1 Like