mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
If an allocation is slow to stop because of `kill_timeout` or `shutdown_delay`, the node drain is marked as complete prematurely, even though drain monitoring will continue to report allocation migrations. This impacts the UI or API clients that monitor node draining to shut down nodes. This changeset updates the behavior to wait until the client status of all drained allocs are terminal before marking the node as done draining.
44 lines
802 B
HCL
44 lines
802 B
HCL
# Copyright (c) HashiCorp, Inc.
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
job "drain_killtimeout" {
|
|
|
|
constraint {
|
|
attribute = "${attr.kernel.name}"
|
|
value = "linux"
|
|
}
|
|
|
|
group "group" {
|
|
|
|
task "task" {
|
|
driver = "docker"
|
|
|
|
kill_timeout = "30s" # matches the agent's max_kill_timeout
|
|
|
|
config {
|
|
image = "busybox:1"
|
|
command = "/bin/sh"
|
|
args = ["local/script.sh"]
|
|
}
|
|
|
|
# this job traps SIGINT so that we can assert that we've forced the drain
|
|
# to wait until the client status has been updated
|
|
template {
|
|
data = <<EOF
|
|
#!/bin/sh
|
|
trap 'sleep 60' 2
|
|
sleep 600
|
|
EOF
|
|
|
|
destination = "local/script.sh"
|
|
change_mode = "noop"
|
|
}
|
|
|
|
resources {
|
|
cpu = 256
|
|
memory = 128
|
|
}
|
|
}
|
|
}
|
|
}
|