Don't trap the EXIT signal twice

killing the worker journal via EXIT signal prevents the cleanup()
function from executing!

NOTE: this is a problem in other scripts as well and needs to be
refactored there too!
This commit is contained in:
Alexander Todorov 2024-02-26 14:41:08 +02:00 committed by Tomáš Hozza
parent 97c0c21513
commit e4b514ca3a

View file

@ -19,6 +19,9 @@ function cleanup() {
$OC_CLI delete pvc "$PVC_NAME"
sudo rm -rf "$TEMPDIR"
# Stop watching the worker journal when exiting.
sudo pkill -P "${WORKER_JOURNAL_PID}"
}
trap cleanup EXIT
@ -96,8 +99,6 @@ sudo composer-cli blueprints depsolve bash
WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
WORKER_JOURNAL_PID=$!
# Stop watching the worker journal when exiting.
trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
# Start the compose and upload to OpenShift
greenprint "🚀 Starting compose"
@ -126,7 +127,6 @@ get_compose_metadata "$COMPOSE_ID"
# Kill the journal monitor immediately and remove the trap
sudo pkill -P ${WORKER_JOURNAL_PID}
trap - EXIT
# Did the compose finish with success?
if [[ $COMPOSE_STATUS != FINISHED ]]; then