Refactor how the 'trap' command is used to avoid double calls
in many files there was a secondary call to `trap` for the sole purpose of killing jornalctl (watching worker logs) so that GitLab CI doesn't hang. The issue with this is that sometimes the cleared the trap which invokes the cleanup() function without reinstating it again (not everywhere). Instead of doing this back-and-forth just make sure we don't leave any journalctl processes dangling in the background! NOTES: - for some scripts, mainly ostree- ones there was no cleanup trap present, but instead `trap` was configured inside the build_image() function. The trouble is that this function is executed multiple times and $WORKER_JOURNAL_PID changes value between these multiple executions. That's why these scripts introduce the cleanup_on_exit() function where we make sure to kill any possible dangling journalctl processes. - The name `cleanup_on_exit()` is chosed because these same scripts often have a helper function named clean_up() which is sometimes used to remove virtual machines and other artifacts between calls of build_image().
This commit is contained in:
parent
c534689d57
commit
85ce42570d
19 changed files with 110 additions and 83 deletions
|
|
@ -32,6 +32,8 @@ fi
|
|||
TEMPDIR=$(mktemp -d)
|
||||
function cleanup() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
sudo rm -rf "$TEMPDIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
|
@ -127,8 +129,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 AWS.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -155,9 +155,8 @@ greenprint "💬 Getting compose log and metadata"
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ fi
|
|||
TEMPDIR=$(mktemp -d)
|
||||
function cleanup() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
sudo rm -rf "$TEMPDIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
|
@ -156,8 +158,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 Azure.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -184,9 +184,8 @@ greenprint "💬 Getting compose log and metadata"
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
|||
TEMPDIR=$(mktemp -d)
|
||||
function cleanup() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
sudo rm -rf "$TEMPDIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
|
@ -82,8 +84,6 @@ sudo composer-cli blueprints depsolve image
|
|||
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 CI registry.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -111,9 +111,8 @@ greenprint "💬 Getting compose log and metadata"
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
|
|||
TEMPDIR=$(mktemp -d)
|
||||
function cleanup() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
sudo rm -rf "$TEMPDIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
|
@ -88,8 +90,6 @@ UPLOAD_TARGET="$CI_REGISTRY_IMAGE/fedora-container:$CI_COMMIT_REF_SLUG"
|
|||
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 CI registry.
|
||||
greenprint "🚀 Starting compose with upload to $UPLOAD_TARGET"
|
||||
|
|
@ -117,9 +117,8 @@ greenprint "💬 Getting compose log and metadata"
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -21,6 +21,13 @@ BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
|
|||
COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
|
||||
COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
|
||||
|
||||
function cleanup_on_exit() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup_on_exit EXIT
|
||||
|
||||
# Workaround the problem that 'image-info' can not read SELinux labels unknown to the host from the image
|
||||
OSBUILD_LABEL=$(matchpathcon -n "$(which osbuild)")
|
||||
sudo chcon "$OSBUILD_LABEL" /usr/libexec/osbuild-composer-test/image-info
|
||||
|
|
@ -41,8 +48,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -53,11 +58,9 @@ build_image() {
|
|||
if [[ $want_fail == "$STATUS" ]]; then
|
||||
redprint "Something went wrong with the compose. 😢"
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
exit 1
|
||||
elif [[ $want_fail == true && $STATUS == false ]]; then
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
# use get_build_info to extract errors before picking the first
|
||||
errors=$(get_build_info ".errors" "$COMPOSE_START")
|
||||
ERROR_MSG=$(jq 'first(.[] | select(.id == "ManifestCreationFailed")) | .msg' <<< "${errors}")
|
||||
|
|
@ -81,9 +84,8 @@ build_image() {
|
|||
sleep 5
|
||||
done
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
@ -97,7 +99,7 @@ clean_up () {
|
|||
greenprint "🧼 Cleaning up"
|
||||
# Remove "remote" repo.
|
||||
sudo rm -f "$IMAGE_FILENAME"
|
||||
# Remomve tmp dir.
|
||||
# Remove tmp dir.
|
||||
sudo rm -rf "$TEMPDIR"
|
||||
}
|
||||
check_result () {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ function cleanupGCP() {
|
|||
TEMPDIR=$(mktemp -d)
|
||||
function cleanup() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
cleanupGCP
|
||||
sudo rm -rf "$TEMPDIR"
|
||||
}
|
||||
|
|
@ -226,8 +228,6 @@ sudo composer-cli blueprints depsolve "$BLUEPRINT_NAME"
|
|||
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 GCP.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -254,11 +254,8 @@ greenprint "💬 Getting compose log and metadata"
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
# trap cleanup again
|
||||
trap cleanup EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -22,9 +22,14 @@ else
|
|||
fi
|
||||
|
||||
TEMPDIR=$(mktemp -d)
|
||||
# note: moved here to avoid undefined variable in cleanup()
|
||||
MINIO_CONTAINER_NAME="minio-server"
|
||||
function cleanup() {
|
||||
echo "== Script execution stopped or finished - Cleaning up =="
|
||||
sudo rm -rf "$TEMPDIR"
|
||||
|
||||
# Kill the MinIO server once we're done
|
||||
${CONTAINER_RUNTIME} kill ${MINIO_CONTAINER_NAME}
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
|
|
@ -60,7 +65,6 @@ fi
|
|||
mkdir "${MINIO_CONFIG_DIR}"
|
||||
$MC_CMD --version
|
||||
|
||||
MINIO_CONTAINER_NAME="minio-server"
|
||||
MINIO_ENDPOINT="http://localhost:9000"
|
||||
MINIO_ROOT_USER="X29DU5Q6C5NKDQ8PLGVT"
|
||||
MINIO_ROOT_PASSWORD=$(date +%s | sha256sum | base64 | head -c 32 ; echo)
|
||||
|
|
@ -88,8 +92,6 @@ ${CONTAINER_RUNTIME} run --rm -d \
|
|||
-e MINIO_ROOT_USER="${MINIO_ROOT_USER}" \
|
||||
-e MINIO_ROOT_PASSWORD="${MINIO_ROOT_PASSWORD}" \
|
||||
${CONTAINER_MINIO_SERVER} server /data
|
||||
# Kill the server once we're done
|
||||
trap '${CONTAINER_RUNTIME} kill ${MINIO_CONTAINER_NAME}' EXIT
|
||||
|
||||
# Configure the local server (retry until the service is up)
|
||||
MINIO_CONFIGURE_RETRY=0
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@ set -euo pipefail
|
|||
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
|
||||
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
||||
|
||||
function cleanup() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Provision the software under test.
|
||||
/usr/libexec/osbuild-composer-test/provision.sh none
|
||||
|
||||
|
|
@ -141,8 +148,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -171,9 +176,8 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ TEMPDIR=$(mktemp -d)
|
|||
function cleanup() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
|
||||
# since this function can be called at any time, ensure that we don't expand unbound variables
|
||||
OC_CLI="${OC_CLI:-}"
|
||||
VM_NAME="${VM_NAME:-}"
|
||||
|
|
@ -24,10 +27,6 @@ function cleanup() {
|
|||
[[ "$OC_CLI" && "$PVC_NAME" ]] && $OC_CLI delete pvc "$PVC_NAME"
|
||||
|
||||
sudo rm -rf "$TEMPDIR"
|
||||
|
||||
# Stop watching the worker journal when exiting.
|
||||
WORKER_JOURNAL_PID="${WORKER_JOURNAL_PID:-}"
|
||||
[ "$WORKER_JOURNAL_PID" ] && sudo pkill -P "$WORKER_JOURNAL_PID"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
|
|
@ -131,7 +130,7 @@ greenprint "💬 Getting compose log and metadata"
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
|
||||
# Did the compose finish with success?
|
||||
|
|
|
|||
|
|
@ -10,6 +10,13 @@ ARCH=$(uname -m)
|
|||
|
||||
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
||||
|
||||
function cleanup_on_exit() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup_on_exit EXIT
|
||||
|
||||
# Start libvirtd and test it.
|
||||
greenprint "🚀 Starting libvirt daemon"
|
||||
sudo systemctl start libvirtd
|
||||
|
|
@ -139,8 +146,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -179,9 +184,8 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -10,6 +10,13 @@ ARCH=$(uname -m)
|
|||
|
||||
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
||||
|
||||
function cleanup_on_exit() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup_on_exit EXIT
|
||||
|
||||
# Install and start firewalld
|
||||
greenprint "🔧 Install and start firewalld"
|
||||
sudo dnf install -y firewalld
|
||||
|
|
@ -158,8 +165,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -193,9 +198,8 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -10,6 +10,13 @@ ARCH=$(uname -m)
|
|||
|
||||
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
||||
|
||||
function cleanup_on_exit() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup_on_exit EXIT
|
||||
|
||||
# Start libvirtd and test it.
|
||||
greenprint "🚀 Starting libvirt daemon"
|
||||
sudo systemctl start libvirtd
|
||||
|
|
@ -136,8 +143,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -173,9 +178,8 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -285,10 +285,6 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
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
|
||||
redprint "Something went wrong with the compose. 😢"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@ ARCH=$(uname -m)
|
|||
|
||||
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
||||
|
||||
function cleanup_on_exit() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup_on_exit EXIT
|
||||
|
||||
# Get compose url if it's running on unsubscried RHEL
|
||||
if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then
|
||||
source /usr/libexec/osbuild-composer-test/define-compose-url.sh
|
||||
|
|
@ -145,8 +152,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -187,9 +192,8 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -10,6 +10,13 @@ ARCH=$(uname -m)
|
|||
|
||||
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
||||
|
||||
function cleanup_on_exit() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup_on_exit EXIT
|
||||
|
||||
# Start libvirtd and test it.
|
||||
greenprint "🚀 Starting libvirt daemon"
|
||||
sudo systemctl start libvirtd
|
||||
|
|
@ -178,8 +185,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -215,9 +220,8 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -10,6 +10,13 @@ ARCH=$(uname -m)
|
|||
|
||||
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
||||
|
||||
function cleanup_on_exit() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup_on_exit EXIT
|
||||
|
||||
# Start firewalld
|
||||
sudo systemctl enable --now firewalld
|
||||
sudo pip3 install yq==v3.2.1
|
||||
|
|
@ -219,8 +226,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -256,9 +261,8 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ ARCH=$(uname -m)
|
|||
|
||||
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
||||
|
||||
function cleanup_on_exit() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup_on_exit EXIT
|
||||
|
||||
|
||||
# Install govc
|
||||
GOVC_VERSION="v0.30.5"
|
||||
sudo curl -L -o - "https://github.com/vmware/govmomi/releases/download/${GOVC_VERSION}/govc_Linux_x86_64.tar.gz" | sudo tar -C /usr/local/bin -xvzf - govc
|
||||
|
|
@ -155,8 +163,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -188,9 +194,8 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@ ARCH=$(uname -m)
|
|||
|
||||
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
|
||||
|
||||
function cleanup_on_exit() {
|
||||
greenprint "== Script execution stopped or finished - Cleaning up =="
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
}
|
||||
trap cleanup_on_exit EXIT
|
||||
|
||||
|
||||
# Get compose url if it's running on unsubscried RHEL
|
||||
if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then
|
||||
source /usr/libexec/osbuild-composer-test/define-compose-url.sh
|
||||
|
|
@ -199,8 +207,6 @@ build_image() {
|
|||
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.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -233,9 +239,8 @@ build_image() {
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ SSH_KEY_PUB=$(cat "$SSH_KEY".pub)
|
|||
function cleanup() {
|
||||
set +eu
|
||||
greenprint "🧼 Cleaning up"
|
||||
# kill dangling journalctl processes to prevent GitLab CI from hanging
|
||||
sudo pkill journalctl || echo "Nothing killed"
|
||||
$GOVC_CMD vm.destroy -u "${GOVMOMI_USERNAME}":"${GOVMOMI_PASSWORD}"@"${GOVMOMI_URL}" -k=true "${IMAGE_KEY}"
|
||||
set -eu
|
||||
}
|
||||
|
|
@ -160,8 +162,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 VMWare.
|
||||
greenprint "🚀 Starting compose"
|
||||
|
|
@ -189,11 +189,8 @@ greenprint "💬 Getting compose log and metadata"
|
|||
get_compose_log "$COMPOSE_ID"
|
||||
get_compose_metadata "$COMPOSE_ID"
|
||||
|
||||
# Kill the journal monitor immediately and remove the trap
|
||||
# while adding just the cleanup trap
|
||||
# Kill the journal monitor
|
||||
sudo pkill -P ${WORKER_JOURNAL_PID}
|
||||
trap - EXIT
|
||||
trap cleanup EXIT
|
||||
|
||||
# Did the compose finish with success?
|
||||
if [[ $COMPOSE_STATUS != FINISHED ]]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue