Files
nomad/e2e/consul/input/on_update_check_restart.nomad
Tim Gross e9ba630639 docker: fix script check execution (#24098)
In #24095 we made a fix for non-streaming exec into Docker tasks for script
checks and `change_mode = "script"`, but didn't complete E2E testing. We need to
use `ContainerExecAttach` in the new API in order to get stdout/stderr from
tasklets, but the previous `ContainerExecStart` call will prevent this from
running successfully with an error that the exec has already run.

* Ref: [NET-11202 (comment)](https://hashicorp.atlassian.net/browse/NET-11202?focusedCommentId=551618)
* This has shipped in Nomad 1.9.0-beta.1 but not production yet.
* This should fix the remaining issues in nightly E2E for Docker.
2024-10-01 16:41:38 -04:00

97 lines
2.0 KiB
HCL

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
job "test" {
datacenters = ["dc1"]
type = "service"
constraint {
attribute = "${attr.kernel.name}"
value = "linux"
}
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 = [
"/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 = <<EOT
#!/bin/sh
if [ ! -f /tmp/check_0 ]; then touch /tmp/check_0; exit 1; fi
if [ ! -f /tmp/check_1 ]; then touch /tmp/check_1; exit 1; fi
if [ ! -f /tmp/check_2 ]; then touch /tmp/check_2; exit 1; fi
if [ ! -f /tmp/check_3 ]; then touch /tmp/check_3; exit 1; fi
if [ ! -f /tmp/check_4 ]; then touch /tmp/check_4; exit 1; fi
if [ ! -f /tmp/check_5 ]; then touch /tmp/check_5; exit 1; fi
if [ ! -f /tmp/check_6 ]; then touch /tmp/check_6; exit 7; fi
if [ ! -f /tmp/check_7 ]; then touch /tmp/check_7; exit 7; fi
if [ ! -f /tmp/check_8 ]; then touch /tmp/check_8; exit 7; fi
if [ ! -f /tmp/check_9 ]; then touch /tmp/check_9; exit 7; fi
if [ -f /tmp/check_9 ]; then exit 7; fi
EOT
destination = "local/ready.sh"
perms = "777"
}
}
}
}