Skip to content

Commit 03107db

Browse files
authored
Merge pull request #4366 from esl/compress-logs-on-s3
Zip MIM logs before uploading to S3
2 parents ee1d5e4 + 3ae6c54 commit 03107db

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

Diff for: tools/circleci-prepare-log-dir.sh

+24-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source tools/circleci-helpers.sh
55
set -euo pipefail
66
IFS=$'\n\t'
77

8+
# Relative directory name
89
CT_REPORTS=$(ct_reports_dir)
910
mkdir -p ${CT_REPORTS}/small
1011
mkdir -p ${CT_REPORTS}/big
@@ -29,14 +30,35 @@ cat > ${CT_REPORTS}/index.html << EOL
2930
</html>
3031
EOL
3132

33+
CT_REPORTS_FULL=$(cd "$CT_REPORTS" && pwd)
34+
3235
now=`date +'%Y-%m-%d_%H.%M.%S'`
33-
LOG_DIR_ROOT=${CT_REPORTS}/logs/${now}
36+
# Replace all occurrences of / with _
37+
PREFIX="${CT_REPORTS//\//_}"
38+
39+
# Optimize naming, so it is easy to extract on MacOS just by clicking it
40+
# and with reasonable directory names
41+
LOG_DIR_ROOT=${CT_REPORTS}/logs/${PREFIX}_${now}
42+
LOG_ZIP=${CT_REPORTS_FULL}/logs_${PREFIX}_${now}.tar.gz
3443
for dev_node_logs_path in `find _build -name log -type d`; do
3544
dev_node=$(basename $(dirname $(dirname $(dirname ${dev_node_logs_path}))))
36-
LOG_DIR=${LOG_DIR_ROOT}/${dev_node}/log
45+
LOG_DIR=${LOG_DIR_ROOT}/${dev_node}/
3746
mkdir -p ${LOG_DIR}
3847
cp ${dev_node_logs_path}/* ${LOG_DIR}
3948
done
4049

4150
cp *.log ${LOG_DIR_ROOT}
4251
cp big_tests/*.log ${LOG_DIR_ROOT} || true
52+
53+
OLD_DIR=$(pwd)
54+
55+
# cd so we don't include nested dirs in the archive (for example, PR/4366/236412)
56+
cd "$LOG_DIR_ROOT/.."
57+
58+
# Zip to safe space
59+
tar -czvf "$LOG_ZIP" "$(basename "$LOG_DIR_ROOT")"
60+
61+
cd "$OLD_DIR"
62+
63+
# Slightly faster than removing
64+
mv "$LOG_DIR_ROOT" /tmp/

0 commit comments

Comments
 (0)