[nomad 101] Getting my head around evaluations

Hi there,

I’m just getting started with nomad, sorry if this is an obvious question but I’m struggling to get my head around what the evaluation is doing when I resubmit a job?

job "job_alpine-batch" {
  datacenters = ["dc1"]
  type = "batch"

  group "group_alpine-batch" {

    task "task_run-date" {
      driver = "docker"

      config {
        image = "alpine:latest"
        command = "/bin/date"
      }

      resources {
        cpu    = 100
        memory = 32
      }
    }
  }
}

I submit the job and it completes

# nomad job run ./batch-alpine.nomad
==> 2021-07-14T14:46:39+01:00: Monitoring evaluation "0477568d"
    2021-07-14T14:46:39+01:00: Evaluation triggered by job "job_alpine-batch"
==> 2021-07-14T14:46:40+01:00: Monitoring evaluation "0477568d"
    2021-07-14T14:46:40+01:00: Allocation "98aca893" created: node "ca13fdd6", group "group_alpine-batch"
    2021-07-14T14:46:40+01:00: Evaluation status changed: "pending" -> "complete"
==> 2021-07-14T14:46:40+01:00: Evaluation "0477568d" finished with status "complete"
# nomad alloc logs 98aca893
Wed Jul 14 13:46:43 UTC 2021

I then submit the job again

# nomad job run ./batch-alpine.nomad
==> 2021-07-14T14:47:00+01:00: Monitoring evaluation "06d1c02a"
    2021-07-14T14:47:00+01:00: Evaluation triggered by job "job_alpine-batch"
==> 2021-07-14T14:47:01+01:00: Monitoring evaluation "06d1c02a"
    2021-07-14T14:47:01+01:00: Evaluation status changed: "pending" -> "complete"
==> 2021-07-14T14:47:01+01:00: Evaluation "06d1c02a" finished with status "complete"
#

For a time I thought that it was running the job again but I could never see the log output change (newbie), so what is it evaluating that it finished?

I’ve tried reading the internals documentation but it doesn’t seem to be sinking in, sorry

For batch jobs in particular to rerun that job will I have to change the job name or possibly use a parametrised job?

Appreciate anyone taking the time to help me out, I promise to pay it forward in the future.

Gary

Hey Gary

So if you’re trying to do batch jobs that are triggered, you probably want to look at a parameterized job (I wouldn’t recommend doing different names). Without that you’re going to be submitting the same job over and over but Nomad won’t detect any changes (note above in your logs you see that no allocation is created or changed).

Could you share the feature you’re trying to implement (for context)?

thanks
Ian

1 Like

Hi @username-is-already :wave:

@idrennanvmware is absolutely correct. A batch job will run once, and only once, unless you modify it. If you need to run the exact same job multiple times, you will need a parameterized batch job.

But this is actually true for all kinds of jobs (system and service being the other two, along with batch). Nomad will not do work unless it has to. If your job didn’t change, Nomad will not do anything.

This is what an evaluation is: it’s a representation of Nomad making a scheduling decision.

In your first log output, the evaluation resulted into an allocation placement (an allocation is an instantiation of a group), since there were no existing allocations that satisfied the evaluation request.

In your second output though, the evaluation completed without a placement because your batch job already ran, and there was no change detected.

I hope this makes the (admittedly very crypt) output more clear. You can find some other term definitions in our Glossary.