azure: Collect systemd boot log

If an error occured while containers setup phase then no logs will
be collected and it is hard(impossible?) to debug such issues on
remote Azure host. With this change in case of such error all the
container's journals will be collected in `systemd_boot_logs`.

Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Stanislav Levin 2021-05-05 19:53:37 +03:00 committed by Alexander Bokovoy
parent a8fd65be65
commit be2f659aa7
2 changed files with 29 additions and 9 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash -eux #!/bin/bash -eux
set -o pipefail
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
echo "Docker environment ID is not provided" echo "Docker environment ID is not provided"
exit 1 exit 1
@ -52,20 +54,30 @@ if [ "$IPA_TESTS_TYPE" == "base" ]; then
IPA_TESTS_REPLICAS="0" IPA_TESTS_REPLICAS="0"
fi fi
function compose_execute() { # path to env dir outside from container
# execute given command within every container of compose project_dir="${IPA_TESTS_ENV_WORKING_DIR}/${IPA_TESTS_ENV_NAME}"
local containers="${PROJECT_ID}_master_1" # path for journal if containers setup fails
SYSTEMD_BOOT_LOG="${project_dir}/systemd_boot_logs"
BASH_CMD="/bin/bash --noprofile --norc"
function containers() {
local _containers="${PROJECT_ID}_master_1"
# build list of replicas # build list of replicas
for i in $(seq 1 1 "$IPA_TESTS_REPLICAS"); do for i in $(seq 1 1 "$IPA_TESTS_REPLICAS"); do
containers+=" ${PROJECT_ID}_replica_${i}" _containers+=" ${PROJECT_ID}_replica_${i}"
done done
# build list of clients # build list of clients
for i in $(seq 1 1 "$IPA_TESTS_CLIENTS"); do for i in $(seq 1 1 "$IPA_TESTS_CLIENTS"); do
containers+=" ${PROJECT_ID}_client_${i}" _containers+=" ${PROJECT_ID}_client_${i}"
done done
printf "$_containers"
}
for container in $containers; do function compose_execute() {
# execute given command within every container of compose
for container in $(containers); do
docker exec -t \ docker exec -t \
"$container" \ "$container" \
"$@" \ "$@" \
@ -74,7 +86,6 @@ function compose_execute() {
done done
} }
project_dir="${IPA_TESTS_ENV_WORKING_DIR}/${IPA_TESTS_ENV_NAME}"
ln -sfr \ ln -sfr \
"${IPA_TESTS_DOCKERFILES}/docker-compose.yml" \ "${IPA_TESTS_DOCKERFILES}/docker-compose.yml" \
"$project_dir"/ "$project_dir"/
@ -107,7 +118,15 @@ IPA_TESTS_ENV_NAME="$IPA_TESTS_ENV_NAME" \
IPA_TEST_CONFIG_TEMPLATE="${BUILD_REPOSITORY_LOCALPATH}/ipatests/azure/templates/ipa-test-config-template.yaml" \ IPA_TEST_CONFIG_TEMPLATE="${BUILD_REPOSITORY_LOCALPATH}/ipatests/azure/templates/ipa-test-config-template.yaml" \
IPA_TESTS_REPO_PATH="$IPA_TESTS_REPO_PATH" \ IPA_TESTS_REPO_PATH="$IPA_TESTS_REPO_PATH" \
IPA_TESTS_DOMAIN="$IPA_TESTS_DOMAIN" \ IPA_TESTS_DOMAIN="$IPA_TESTS_DOMAIN" \
python3 setup_containers.py python3 setup_containers.py || \
{ mkdir -p "$SYSTEMD_BOOT_LOG";
for container in $(containers); do
docker exec -t "$container" \
$BASH_CMD -eu \
-c 'journalctl -b --no-pager' > "${SYSTEMD_BOOT_LOG}/systemd_boot_${container}.log";
done
exit 1;
}
# path to runner within container # path to runner within container
tests_runner="${IPA_TESTS_REPO_PATH}/${IPA_TESTS_SCRIPTS}/azure-run-${IPA_TESTS_TYPE}-tests.sh" tests_runner="${IPA_TESTS_REPO_PATH}/${IPA_TESTS_SCRIPTS}/azure-run-${IPA_TESTS_TYPE}-tests.sh"
@ -123,7 +142,7 @@ tests_result=1
--env IPA_TESTS_TO_IGNORE="$IPA_TESTS_TO_IGNORE" \ --env IPA_TESTS_TO_IGNORE="$IPA_TESTS_TO_IGNORE" \
--env IPA_TESTS_ARGS="$IPA_TESTS_ARGS" \ --env IPA_TESTS_ARGS="$IPA_TESTS_ARGS" \
"$IPA_TESTS_CONTROLLER" \ "$IPA_TESTS_CONTROLLER" \
/bin/bash --noprofile --norc \ $BASH_CMD \
-eux "$tests_runner" && tests_result=0 ; } || tests_result=$? -eux "$tests_runner" && tests_result=0 ; } || tests_result=$?
echo "Report disk usage" echo "Report disk usage"

View File

@ -150,6 +150,7 @@ steps:
!*/*.yml !*/*.yml
!*/*.yaml !*/*.yaml
!*/*.log !*/*.log
!*/systemd_boot_logs/*.log
!*.tar.gz !*.tar.gz
EOF EOF
cat "$artifacts_ignore_path" cat "$artifacts_ignore_path"