From 88fd96daea4f6e651c5fddfd98a6e5d0b0cd2386 Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Thu, 5 Oct 2023 10:40:50 -0500 Subject: [PATCH] backport of commit ed204e0fd985bbb43da7e19e07cf541ad74284a8 (#18670) Co-authored-by: Luiz Aoqui --- .changelog/18662.txt | 3 +++ client/allocrunner/taskrunner/task_runner.go | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 .changelog/18662.txt diff --git a/.changelog/18662.txt b/.changelog/18662.txt new file mode 100644 index 000000000..6621656b0 --- /dev/null +++ b/.changelog/18662.txt @@ -0,0 +1,3 @@ +```release-note:bug +client: prevent tasks from starting without the prestart hooks running +``` diff --git a/client/allocrunner/taskrunner/task_runner.go b/client/allocrunner/taskrunner/task_runner.go index 3f64299ed..7800e753b 100644 --- a/client/allocrunner/taskrunner/task_runner.go +++ b/client/allocrunner/taskrunner/task_runner.go @@ -591,6 +591,12 @@ MAIN: goto RESTART } + // Check for a terminal allocation once more before proceeding as the + // prestart hooks may have been skipped. + if tr.shouldShutdown() { + break MAIN + } + select { case <-tr.killCtx.Done(): break MAIN