From 1f396d8c16e179aa5b7b9ea1da6b16fb0b167016 Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Mon, 12 Jul 2021 09:59:40 -0700 Subject: Prevent the cleanup script from destroying any "bootstrap" containers. PiperOrigin-RevId: 384257460 --- .buildkite/hooks/post-command | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.buildkite/hooks/post-command b/.buildkite/hooks/post-command index c4c6fc90c..5e6db407a 100644 --- a/.buildkite/hooks/post-command +++ b/.buildkite/hooks/post-command @@ -56,8 +56,10 @@ if test "${BUILDKITE_COMMAND_EXIT_STATUS}" -ne "0"; then sudo rm -rf "${HOME}/go" fi -# Kill any running containers (clear state). -CONTAINERS="$(docker ps -q)" -if ! test -z "${CONTAINERS}"; then - docker container kill ${CONTAINERS} 2>/dev/null || true -fi +# Kill any running containers (clear state), except for "bootstrap". +for container in $(docker ps -q); do + maybe_kill="$(docker inspect -f '{{if ne "/bootstrap" .Name}}true{{ end }}' "${container}")" + if test -n "${maybe_kill}"; then + docker container kill "${container}" + fi +done \ No newline at end of file -- cgit v1.2.3