I’m playing with a simple job to see how nomad handles failures (with https://github.com/ThomasObenaus/dummy-services/tree/master/fail_service). Cluster contains 3 servers (all running consul/nomad server and client), but the job is constrained to run on one specific server, 1 instance. Nomad handles failures as expected via restarting the job. But what I noticed that services from consul isn’t deregistered and grow over time, see screenshot:
Job is fairly simple (see below). My assumption that services should be removed when allocation stopped. Am I wrong? Is it a bug with nomad?
job "fail" {
datacenters = ["dc"]
constraint {
attribute = "${attr.unique.consul.name}"
operator = "regexp"
value = "^(hjk)$"
}
update {
healthy_deadline = "30s"
progress_deadline = "40s"
min_healthy_time = "0s"
}
group "fail" {
count = "1"
network {
port "http" {
to = 8080
}
}
service {
port = "http"
check {
port = "http"
type = "http"
path = "/health"
method = "GET"
interval = "10s"
timeout = "2s"
check_restart {
limit = 1
}
}
}
task "fail" {
driver = "docker"
config {
image = "thobe/fail_service:latest"
ports = ["http"]
}
env {
HEALTHY_FOR = 60
UNHEALTHY_FOR = -1
}
}
}
}