diff --git a/e2e/consul/input/on_update.nomad b/e2e/consul/input/on_update.nomad index 951b5f0a8..ac094a506 100644 --- a/e2e/consul/input/on_update.nomad +++ b/e2e/consul/input/on_update.nomad @@ -15,7 +15,7 @@ job "test" { } service { - name = "echo-service" + name = "on-update-service" port = "db" check { diff --git a/e2e/consul/input/on_update_check_restart.nomad b/e2e/consul/input/on_update_check_restart.nomad new file mode 100644 index 000000000..3d0286ee3 --- /dev/null +++ b/e2e/consul/input/on_update_check_restart.nomad @@ -0,0 +1,88 @@ +job "test" { + datacenters = ["dc1"] + + group "test" { + count = 1 + + network { + port "db" { + to = 6379 + } + } + + update { + health_check = "checks" + progress_deadline = "45s" + healthy_deadline = "30s" + } + + service { + name = "script-check-svc" + port = "db" + + check { + name = "tcp" + type = "tcp" + port = "db" + interval = "10s" + timeout = "2s" + } + + check { + name = "script-check-script" + type = "script" + command = "/bin/bash" + interval = "5s" + timeout = "1s" + task = "server" + on_update = "ignore_warnings" + + args = [ + "-c", + "/local/ready.sh" + ] + + check_restart { + limit = 2 + ignore_warnings = true + } + } + } + + + task "server" { + driver = "docker" + + config { + image = "redis" + ports = ["db"] + } + + # Check script that reports as warning for long enough for deployment to + # become healthy then errors + template { + data = <value maps, each describing the values // of the 'nomad node status' Allocations section (not actual // structs.Allocation objects, query the API if you want those) @@ -116,6 +149,21 @@ func AllocStatuses(jobID, ns string) ([]string, error) { return statuses, nil } +// AllocStatuses returns a slice of client statuses +func AllocTaskEvents(jobID, ns string) ([]string, error) { + + allocs, err := AllocsForJob(jobID, ns) + if err != nil { + return nil, err + } + + statuses := []string{} + for _, alloc := range allocs { + statuses = append(statuses, alloc["Status"]) + } + return statuses, nil +} + // AllocStatusesRescheduled is a helper function that pulls // out client statuses only from rescheduled allocs. func AllocStatusesRescheduled(jobID, ns string) ([]string, error) {