From 02b9720bc6f4f0b3d57faf09f2475ec4617a19d5 Mon Sep 17 00:00:00 2001 From: yihau Date: Tue, 27 Jun 2023 16:34:35 +0800 Subject: [PATCH] ci: only kill containers that are based on the solanalabs/rust* images --- .buildkite/hooks/post-checkout | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.buildkite/hooks/post-checkout b/.buildkite/hooks/post-checkout index e4893c67dd4c8a..0804f46639a178 100644 --- a/.buildkite/hooks/post-checkout +++ b/.buildkite/hooks/post-checkout @@ -10,14 +10,18 @@ source ci/env.sh # previous CI job # ( - containers=$(docker ps -q) - if [[ $(hostname) != metrics-main && $(hostname) != metrics-internal && -n $containers ]]; then - echo "+++ Killing stale docker containers" - docker ps + echo "+++ Killing stale docker containers" + while read -r line; do + id="$(echo "$line" | awk '{print $1}')" + image="$(echo "$line" | awk '{print $2}')" - # shellcheck disable=SC2086 # Don't want to double quote $containers - docker kill $containers - fi + if [[ $image == *"solanalabs/rust"* ]]; then + if docker kill "$id" >/dev/null; then + echo "kill $id $image" + fi + continue + fi + done < <(docker ps | tail -n +2) ) # Processes from previously aborted CI jobs seem to loiter, unclear why as one