From the documentation it is clearly said:
Plan will return one of the following exit codes:
0: No allocations created or destroyed.
1: Allocations created or destroyed.
Ok, this is good, but if I make a change that doesn’t require a new allocation to be created or destroyed, but only updated, the status code is 0.
For me, this is wrong reasoning:
Concider for example, the following simplified jobspec:
job "foo" {
type = "service"
group "foo" {
task "foo" {
service {
name = "foo"
}
driver = "docker"
config {
image = "foo:latest"
}
}
}
}
If I change the service name to `bar`:
$ nomad job plan path/to/foo.hcl
+/- Job: "foo"
+/- Task Group: "foo" (1 in-place update)
+/- Task: "foo" (forces in-place update)
+/- Service {
Address: ""
AddressMode: "auto"
Cluster: "default"
EnableTagOverride: "false"
Kind: ""
+/- Name: "foo" => "bar"
Namespace: "default"
OnUpdate: "require_healthy"
PortLabel: "http"
Provider: "consul"
TaskName: "foo"
}
Even if this change has no direct effect on the allocation, it has important side effects, for example, for Consul service registration or Fabio routing (which are very well integrated with Nomad)
From an external point of view, this doesn’t seem to be an issue because `nomad job plan` always prints the diff to stdout.
However, in my case I’m calling `nomad` from a script, and I base the decision on the return code, which is in this case 0:
$ echo $?
0
On the other hand, if `nomad job plan` behaved like this:
Plan will return one of the following exit codes:
0: No allocations created, destroyed or updated
1: Allocations created, destroyed or updated
then it could be used from both CLI and a script.
Or is there another approach that I am missing?
Thank you