github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/e2eutil/input/disconnect-node.nomad (about) 1 variable "nodeID" { 2 type = string 3 } 4 5 variable "time" { 6 type = string 7 default = "0" 8 } 9 10 job "disconnect-node" { 11 type = "batch" 12 datacenters = ["dc1", "dc2"] 13 14 group "group" { 15 16 reschedule { 17 attempts = 0 18 unlimited = false 19 } 20 21 # need to prevent the task from being restarted on reconnect, if 22 # we're stopped long enough for the node to be marked down 23 max_client_disconnect = "1h" 24 25 constraint { 26 attribute = "${attr.kernel.name}" 27 value = "linux" 28 } 29 constraint { 30 attribute = "${node.unique.id}" 31 value = "${var.nodeID}" 32 } 33 34 task "task" { 35 driver = "raw_exec" 36 user = "root" 37 config { 38 command = "/bin/sh" 39 args = ["-c", 40 # before disconnecting, we need to sleep long enough for the 41 # task to register itself, otherwise we end up trying to 42 # re-run the task immediately on reconnect 43 "sleep 5; iptables -I OUTPUT -p tcp --dport 4647 -j DROP; sleep ${var.time}; iptables -D OUTPUT -p tcp --dport 4647 -j DROP"] 44 } 45 } 46 47 } 48 }