diff --git a/.github/actions/scripts/save-coredump.sh b/.github/actions/scripts/save-coredump.sh new file mode 100755 index 000000000..0296a05c4 --- /dev/null +++ b/.github/actions/scripts/save-coredump.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +bucket_name=$S3_BUCKET_NAME +bucket_prefix=$S3_BUCKET_TEST_PREFIX +coredump_path=/var/lib/systemd/coredump/ +coredump_pattern=core.mountpoint_s3* + +# upload core dump files to S3 +aws s3 cp ${coredump_path} s3://${bucket_name}/${bucket_prefix}coredump/ --recursive --exclude "*" --include "${coredump_pattern}" + +# get all core dump records to find their associated binary files +coredump_records=`coredumpctl --no-legend | awk '{print $5,$10}'` + +while IFS= read -r line; do + # get the pid to help matching it with the core dump + pid=`echo $line | awk '{print $1}'` + binary_path=`echo $line | awk '{print $2}'` + binary_name=$(basename $binary_path) + # upload each binary to S3 + aws s3 cp ${binary_path} s3://${bucket_name}/${bucket_prefix}binary/${pid}_${binary_name} +done <<< "$coredump_records" diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 95fcfd5a1..4754e3783 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -83,7 +83,7 @@ jobs: run: cargo test --features $RUST_FEATURES - name: Save dump files if: ${{ failure() && matrix.runner.name == 'Amazon Linux arm' }} - run: aws s3 cp /var/lib/systemd/coredump/ s3://${{ env.S3_BUCKET_NAME }}/${{ env.S3_BUCKET_TEST_PREFIX }}coredump/ --recursive --exclude "*" --include "core.mountpoint_s3*" + run: ./.github/actions/scripts/save-coredump.sh s3express-test: name: S3 Express One Zone tests (${{ matrix.runner.name }}, FUSE ${{ matrix.fuseVersion }}) @@ -131,7 +131,7 @@ jobs: run: cargo test --features '${{ env.RUST_FEATURES }},s3express_tests' - name: Save dump files if: ${{ failure() && matrix.runner.name == 'Amazon Linux arm' }} - run: aws s3 cp /var/lib/systemd/coredump/ s3://${{ env.S3_EXPRESS_ONE_ZONE_BUCKET_NAME }}/${{ env.S3_BUCKET_TEST_PREFIX }}coredump/ --recursive --exclude "*" --include "core.mountpoint_s3*" + run: ./.github/actions/scripts/save-coredump.sh asan: name: Address sanitizer @@ -171,4 +171,4 @@ jobs: run: make test-asan - name: Save dump files if: ${{ failure() }} - run: aws s3 cp /var/lib/systemd/coredump/ s3://${{ env.S3_BUCKET_NAME }}/${{ env.S3_BUCKET_TEST_PREFIX }}coredump/ --recursive --exclude "*" --include "core.mountpoint_s3*" + run: ./.github/actions/scripts/save-coredump.sh