Fix random kills during pre-commit image building (#11535)

Seems like the trap with several steps and || true does not really
work the way I wanted and when kill is run but the process is
already gone, we had error in the script.

Looks like this approach with sub-process kill will do it.
This commit is contained in:
Jarek Potiuk 2020-10-18 23:50:50 +02:00 коммит произвёл GitHub
Родитель 4655409982
Коммит bf79578ed0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -519,8 +519,8 @@ function build_images::build_ci_image() {
" >"${DETECTED_TERMINAL}" " >"${DETECTED_TERMINAL}"
spinner::spin "${OUTPUT_LOG}" & spinner::spin "${OUTPUT_LOG}" &
SPIN_PID=$! SPIN_PID=$!
# shellcheck disable=SC2064 # shellcheck disable=SC2064,SC2016
traps::add_trap "kill ${SPIN_PID} || true" INT TERM HUP EXIT traps::add_trap '$(kill '${SPIN_PID}' || true)' EXIT HUP INT TERM
fi fi
push_pull_remove_images::pull_ci_images_if_needed push_pull_remove_images::pull_ci_images_if_needed
if [[ "${DOCKER_CACHE}" == "disabled" ]]; then if [[ "${DOCKER_CACHE}" == "disabled" ]]; then
@ -557,8 +557,8 @@ function build_images::build_ci_image() {
" >"${DETECTED_TERMINAL}" " >"${DETECTED_TERMINAL}"
spinner::spin "${OUTPUT_LOG}" & spinner::spin "${OUTPUT_LOG}" &
SPIN_PID=$! SPIN_PID=$!
# shellcheck disable=SC2064 # shellcheck disable=SC2064,SC2016
traps::add_trap "kill ${SPIN_PID} || true" EXIT HUP INT TERM traps::add_trap '$(kill '${SPIN_PID}' || true)' EXIT HUP INT TERM
fi fi
if [[ -n ${DETECTED_TERMINAL=} ]]; then if [[ -n ${DETECTED_TERMINAL=} ]]; then
echo -n " echo -n "