2023-04-25 08:49:58 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-07-04 10:26:32 -07:00
|
|
|
CI_BUILD_START=$(date +%s)
|
|
|
|
export CI_BUILD_START
|
2019-01-31 11:56:15 -08:00
|
|
|
|
2019-06-06 12:20:47 -07:00
|
|
|
source ci/env.sh
|
|
|
|
|
2019-02-06 13:39:19 -08:00
|
|
|
#
|
|
|
|
# Kill any running docker containers, which are potentially left over from the
|
|
|
|
# previous CI job
|
|
|
|
#
|
|
|
|
(
|
2023-06-28 21:18:03 -07:00
|
|
|
echo "+++ Killing stale docker containers"
|
|
|
|
while read -r line; do
|
|
|
|
read -r id image _ <<<"$line"
|
2019-02-06 13:39:19 -08:00
|
|
|
|
2023-06-28 21:18:03 -07:00
|
|
|
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)
|
2019-02-06 13:39:19 -08:00
|
|
|
)
|
|
|
|
|
2019-01-31 11:56:15 -08:00
|
|
|
# Processes from previously aborted CI jobs seem to loiter, unclear why as one
|
|
|
|
# would expect the buildkite-agent to clean up all child processes of the
|
|
|
|
# aborted CI job.
|
|
|
|
# But as a workaround for now manually kill some known loiterers. These
|
|
|
|
# processes will all have the `init` process as their PPID:
|
|
|
|
(
|
|
|
|
victims=
|
|
|
|
for name in bash cargo docker solana; do
|
|
|
|
victims="$victims $(pgrep -u "$(id -u)" -P 1 -d \ $name)"
|
|
|
|
done
|
|
|
|
for victim in $victims; do
|
|
|
|
echo "Killing pid $victim"
|
|
|
|
kill -9 "$victim" || true
|
|
|
|
done
|
|
|
|
)
|