[skip e2e]Add script to export containers log one by one (#17138)

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
zhuwenxing 2022-05-20 22:53:59 +08:00 committed by GitHub
parent 5344dbd2b6
commit 5256d2c3f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -146,7 +146,7 @@ jobs:
run: |
docker-compose ps -a || true
mkdir -p logs
docker-compose logs > ./logs/test-${{ matrix.mode }}-${{ matrix.task }}.log 2>&1 || echo "export logs failed"
bash ../../../scripts/export_log_docker.sh ./logs || echo "export logs failed"
- name: 'Send mail'
if: ${{ failure() }}
uses: dawidd6/action-send-mail@v3

View File

@ -0,0 +1,19 @@
#!/bin/bash
# Exit immediately for non zero status
set -e
log_dir=${1:-"logs"}
array=($(docker-compose ps -a|awk 'NR == 1 {next} {print $1}'))
echo ${array[@]}
if [ ! -d $log_dir ];
then
mkdir -p $log_dir
fi
echo "export logs start"
for container in ${array[*]}
do
echo "export logs for container $container "
docker logs $container > ./$log_dir/$container.log 2>&1 || echo "export logs for container $container failed"
done
echo "export logs done"