Files
nomad/e2e/e2eutil/input/disconnect-node.nomad
Seth Hoenig 6e4410a9b1 e2e: fix 1 of 4 client disconnect tests (#15357)
This PR modifies the disconnect helper job to run as root, which is necesary
for manipulating iptables as it does. Also re-organizes the final test logic
to wait for client re-connect before looking for the replacement (3rd) allocation
in case that client was needed to run the alloc (also giving the sheduler more
time to do its thing).

Skips the other 3 tests, which fail and I cannot yet figure out what is going on.
2022-11-22 08:51:53 -06:00

49 lines
1.1 KiB
HCL

variable "nodeID" {
type = string
}
variable "time" {
type = string
default = "0"
}
job "disconnect-node" {
type = "batch"
datacenters = ["dc1", "dc2"]
group "group" {
reschedule {
attempts = 0
unlimited = false
}
# need to prevent the task from being restarted on reconnect, if
# we're stopped long enough for the node to be marked down
max_client_disconnect = "1h"
constraint {
attribute = "${attr.kernel.name}"
value = "linux"
}
constraint {
attribute = "${node.unique.id}"
value = "${var.nodeID}"
}
task "task" {
driver = "raw_exec"
user = "root"
config {
command = "/bin/sh"
args = ["-c",
# before disconnecting, we need to sleep long enough for the
# task to register itself, otherwise we end up trying to
# re-run the task immediately on reconnect
"sleep 5; iptables -I OUTPUT -p tcp --dport 4647 -j DROP; sleep ${var.time}; iptables -D OUTPUT -p tcp --dport 4647 -j DROP"]
}
}
}
}