Skip to content

Commit

Permalink
backport drain improvements #16823 #16826 and #16868
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross authored Apr 12, 2023
2 parents 73565e3 + f26cf29 commit fad61b1
Show file tree
Hide file tree
Showing 9 changed files with 419 additions and 395 deletions.
2 changes: 1 addition & 1 deletion e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
_ "github.com/hashicorp/nomad/e2e/metrics"
_ "github.com/hashicorp/nomad/e2e/namespaces"
_ "github.com/hashicorp/nomad/e2e/networking"
_ "github.com/hashicorp/nomad/e2e/nodedrain"
_ "github.com/hashicorp/nomad/e2e/nomadexec"
_ "github.com/hashicorp/nomad/e2e/oversubscription"
_ "github.com/hashicorp/nomad/e2e/parameterized"
Expand All @@ -42,6 +41,7 @@ import (
// these are no longer on the old framework but by importing them
// we get a quick check that they compile on every commit
_ "github.com/hashicorp/nomad/e2e/disconnectedclients"
_ "github.com/hashicorp/nomad/e2e/nodedrain"
_ "github.com/hashicorp/nomad/e2e/volumes"
)

Expand Down
4 changes: 4 additions & 0 deletions e2e/nodedrain/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package nodedrain

// This package contains only tests, so this is a placeholder file to
// make sure builds don't fail with "no non-test Go files in" errors
25 changes: 9 additions & 16 deletions e2e/nodedrain/input/drain_deadline.nomad
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
job "drain_deadline" {
datacenters = ["dc1", "dc2"]

constraint {
attribute = "${attr.kernel.name}"
value = "linux"
}

migrate {
max_parallel = 1
min_healthy_time = "30s"
}

group "group" {

count = 2

task "task" {
driver = "docker"

kill_timeout = "2m"

config {
image = "busybox:1"
command = "/bin/sh"
args = ["local/script.sh"]
}

template {
data = <<EOF
#!/bin/sh
trap 'sleep 60' 2
sleep 600
EOF

destination = "local/script.sh"
change_mode = "noop"
args = ["-c", "sleep 600"]
}

resources {
cpu = 256
memory = 128
memory = 64
}
}
}
Expand Down
1 change: 0 additions & 1 deletion e2e/nodedrain/input/drain_ignore_system.nomad
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
job "drain_ignore_system_service" {
datacenters = ["dc1", "dc2"]

type = "system"

Expand Down
18 changes: 1 addition & 17 deletions e2e/nodedrain/input/drain_migrate.nomad
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
job "drain_migrate" {
datacenters = ["dc1", "dc2"]

constraint {
attribute = "${attr.kernel.name}"
Expand All @@ -19,22 +18,7 @@ job "drain_migrate" {
config {
image = "busybox:1"
command = "/bin/sh"
args = ["local/test.sh"]
}

template {
data = <<EOT
#!/bin/sh
if [ ! -f /alloc/data/{{ env "NOMAD_JOB_NAME" }} ]; then
echo writing {{ env "NOMAD_ALLOC_ID" }} to /alloc/data/{{ env "NOMAD_JOB_NAME" }}
echo {{ env "NOMAD_ALLOC_ID" }} > /alloc/data/{{ env "NOMAD_JOB_NAME" }}
else
echo /alloc/data/{{ env "NOMAD_JOB_NAME" }} already exists
fi
sleep 3600
EOT

destination = "local/test.sh"
args = ["-c", "echo \"data from $NOMAD_ALLOC_ID\" >> /alloc/data/migrate.txt && sleep 120"]
}

resources {
Expand Down
1 change: 0 additions & 1 deletion e2e/nodedrain/input/drain_simple.nomad
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
job "drain_simple" {
datacenters = ["dc1", "dc2"]

constraint {
attribute = "${attr.kernel.name}"
Expand Down
Loading

0 comments on commit fad61b1

Please sign in to comment.