Skip to content

Commit

Permalink
Improve coredump script for the tests workflow (awslabs#899)
Browse files Browse the repository at this point in the history
* List core dump records when tests are failing

Signed-off-by: Monthon Klongklaew <[email protected]>

* Improve the coredump script

Signed-off-by: Monthon Klongklaew <[email protected]>

---------

Signed-off-by: Monthon Klongklaew <[email protected]>
  • Loading branch information
monthonk authored Jun 3, 2024
1 parent 4ad9b8a commit 9bdb237
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions .github/actions/scripts/save-coredump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@

bucket_name=$S3_BUCKET_NAME
bucket_prefix=$S3_BUCKET_TEST_PREFIX
coredump_path=/var/lib/systemd/coredump/
coredump_pattern=core.*

# upload core dump files to S3
aws s3 cp ${coredump_path} s3://${bucket_name}/${bucket_prefix}coredump/ --recursive --exclude "*" --include "${coredump_pattern}"
# list coredump records
coredumpctl list

# get all core dump records to find their associated binary files
# get all coredump records to find their associated binary files
coredump_records=`coredumpctl --no-legend | awk '{print $5,$10}'`

if [ -z "${coredump_records}" ]; then
# no coredump found so we can stop
exit 0
fi

while IFS= read -r line; do
# get the pid to help matching it with the core dump
# get the pid to help matching it with the coredump
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}

coredump_filename=core_${pid}_${binary_name}
coredump_path=${HOME}/${coredump_filename}
coredumpctl dump ${pid} --output=${coredump_path}
# upload each coredump file to S3
aws s3 cp ${coredump_path} s3://${bucket_name}/${bucket_prefix}coredump/${coredump_filename}
done <<< "$coredump_records"

0 comments on commit 9bdb237

Please sign in to comment.