From c85df48091702a9d5b7101ed7a13b308111b1838 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Tue, 27 Aug 2024 18:53:59 +0200 Subject: [PATCH 1/3] Zip MIM logs before uploading to S3 --- tools/circleci-prepare-log-dir.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/circleci-prepare-log-dir.sh b/tools/circleci-prepare-log-dir.sh index aae5740d701..5e9347c5644 100755 --- a/tools/circleci-prepare-log-dir.sh +++ b/tools/circleci-prepare-log-dir.sh @@ -31,12 +31,19 @@ EOL now=`date +'%Y-%m-%d_%H.%M.%S'` LOG_DIR_ROOT=${CT_REPORTS}/logs/${now} +LOG_ZIP=${CT_REPORTS}/logs_${now}.zip for dev_node_logs_path in `find _build -name log -type d`; do dev_node=$(basename $(dirname $(dirname $(dirname ${dev_node_logs_path})))) - LOG_DIR=${LOG_DIR_ROOT}/${dev_node}/log + LOG_DIR=${LOG_DIR_ROOT}/${dev_node}/ mkdir -p ${LOG_DIR} cp ${dev_node_logs_path}/* ${LOG_DIR} done cp *.log ${LOG_DIR_ROOT} cp big_tests/*.log ${LOG_DIR_ROOT} || true + +# Zip to safe space +zip -9 -r "$LOG_ZIP" "$LOG_DIR_ROOT" + +# Slightly faster than removing +mv "$LOG_DIR_ROOT" /tmp/ From 74935fa0ef2c7108465831f171398b49c7ff5b96 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Tue, 27 Aug 2024 21:39:15 +0200 Subject: [PATCH 2/3] Better directory naming for logs zip file --- tools/circleci-prepare-log-dir.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/circleci-prepare-log-dir.sh b/tools/circleci-prepare-log-dir.sh index 5e9347c5644..86b3ae0740e 100755 --- a/tools/circleci-prepare-log-dir.sh +++ b/tools/circleci-prepare-log-dir.sh @@ -5,6 +5,7 @@ source tools/circleci-helpers.sh set -euo pipefail IFS=$'\n\t' +# Relative directory name CT_REPORTS=$(ct_reports_dir) mkdir -p ${CT_REPORTS}/small mkdir -p ${CT_REPORTS}/big @@ -29,9 +30,16 @@ cat > ${CT_REPORTS}/index.html << EOL EOL +CT_REPORTS_FULL=$(cd "$CT_REPORTS" && pwd) + now=`date +'%Y-%m-%d_%H.%M.%S'` -LOG_DIR_ROOT=${CT_REPORTS}/logs/${now} -LOG_ZIP=${CT_REPORTS}/logs_${now}.zip +# Replace all occurrences of / with _ +PREFIX="${CT_REPORTS//\//_}" + +# Optimize naming, so it is easy to extract on MacOS just by clicking it +# and with reasonable directory names +LOG_DIR_ROOT=${CT_REPORTS}/logs/${PREFIX}_${now} +LOG_ZIP=${CT_REPORTS_FULL}/logs_${PREFIX}_${now}.zip for dev_node_logs_path in `find _build -name log -type d`; do dev_node=$(basename $(dirname $(dirname $(dirname ${dev_node_logs_path})))) LOG_DIR=${LOG_DIR_ROOT}/${dev_node}/ @@ -42,8 +50,15 @@ done cp *.log ${LOG_DIR_ROOT} cp big_tests/*.log ${LOG_DIR_ROOT} || true +OLD_DIR=$(pwd) + +# cd so we don't include nested dirs in the archive (for example, PR/4366/236412) +cd "$LOG_DIR_ROOT/.." + # Zip to safe space -zip -9 -r "$LOG_ZIP" "$LOG_DIR_ROOT" +zip -9 -r "$LOG_ZIP" "$(basename "$LOG_DIR_ROOT")" + +cd "$OLD_DIR" # Slightly faster than removing mv "$LOG_DIR_ROOT" /tmp/ From 3ae6c547fd6314316e78d77238d6b36aaafb003e Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Wed, 28 Aug 2024 16:00:01 +0200 Subject: [PATCH 3/3] Use tar.gz instead of zip Better compression ratio --- tools/circleci-prepare-log-dir.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/circleci-prepare-log-dir.sh b/tools/circleci-prepare-log-dir.sh index 86b3ae0740e..a42a8dec1ab 100755 --- a/tools/circleci-prepare-log-dir.sh +++ b/tools/circleci-prepare-log-dir.sh @@ -39,7 +39,7 @@ PREFIX="${CT_REPORTS//\//_}" # Optimize naming, so it is easy to extract on MacOS just by clicking it # and with reasonable directory names LOG_DIR_ROOT=${CT_REPORTS}/logs/${PREFIX}_${now} -LOG_ZIP=${CT_REPORTS_FULL}/logs_${PREFIX}_${now}.zip +LOG_ZIP=${CT_REPORTS_FULL}/logs_${PREFIX}_${now}.tar.gz for dev_node_logs_path in `find _build -name log -type d`; do dev_node=$(basename $(dirname $(dirname $(dirname ${dev_node_logs_path})))) LOG_DIR=${LOG_DIR_ROOT}/${dev_node}/ @@ -56,7 +56,7 @@ OLD_DIR=$(pwd) cd "$LOG_DIR_ROOT/.." # Zip to safe space -zip -9 -r "$LOG_ZIP" "$(basename "$LOG_DIR_ROOT")" +tar -czvf "$LOG_ZIP" "$(basename "$LOG_DIR_ROOT")" cd "$OLD_DIR"