Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 2af3250

Browse files
Merge pull request #6083 from adityamandaleeka/upload_ci_dumps
Start using dumpling service to upload dumps from CI runs
2 parents 07fd84e + aeb0d3b commit 2af3250

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

tests/runtest.sh

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -576,26 +576,61 @@ function print_info_from_core_file {
576576
gdb --batch -ex "thread apply all bt full" -ex "quit" $executable_name $core_file_name
577577
}
578578

579-
function copy_core_file_to_temp_location {
579+
function download_dumpling_script {
580+
echo "Downloading latest version of dumpling script."
581+
wget "https://raw.githubusercontent.com/Microsoft/dotnet-reliability/master/src/triage.python/dumpling.py"
582+
583+
local dumpling_script="dumpling.py"
584+
chmod +x $dumpling_script
585+
}
586+
587+
function upload_core_file_to_dumpling {
588+
local core_file_name=$1
589+
local dumpling_script="dumpling.py"
590+
591+
if [ ! -x $dumpling_script ]; then
592+
download_dumpling_script
593+
fi
594+
595+
if [ ! -x $dumpling_script ]; then
596+
echo "Failed to download dumpling script. Dump cannot be uploaded."
597+
return
598+
fi
599+
600+
echo "Uploading $core_file_name to dumpling service."
601+
602+
local paths_to_add=""
603+
if [ -d "$coreClrBinDir" ]; then
604+
echo "Uploading CoreCLR binaries with dump."
605+
paths_to_add=$coreClrBinDir
606+
fi
607+
608+
# The output from this will include a unique ID for this dump.
609+
./$dumpling_script "--corefile" "$core_file_name" "upload" "--addpaths" $paths_to_add
610+
}
611+
612+
function preserve_core_file {
580613
local core_file_name=$1
581614
local storage_location="/tmp/coredumps_coreclr"
582615

583616
# Create the directory (this shouldn't fail even if it already exists).
584617
mkdir -p $storage_location
585618

586-
# Only copy the file over if the directory is empty. Otherwise, do nothing.
619+
# Only preserve the dump if the directory is empty. Otherwise, do nothing.
620+
# This is a way to prevent us from storing/uploading too many dumps.
587621
if [ ! "$(ls -A $storage_location)" ]; then
588622
echo "Copying core file $core_file_name to $storage_location"
589623
cp $core_file_name $storage_location
624+
625+
upload_core_file_to_dumpling $core_file_name
590626
fi
591627
}
592628

593629
function inspect_and_delete_core_files {
594630
# This function prints some basic information from core files in the current
595631
# directory and deletes them immediately. Based on the state of the system, it may
596-
# also store one core file in a non-transient directory so that it's available
597-
# after the run is complete even if the directory for the run is deleted
598-
# (see copy_core_file_to_temp_location).
632+
# also upload a core file to the dumpling service.
633+
# (see preserve_core_file).
599634

600635
# Depending on distro/configuration, the core files may either be named "core"
601636
# or "core.<PID>" by default. We will read /proc/sys/kernel/core_uses_pid to
@@ -609,11 +644,11 @@ function inspect_and_delete_core_files {
609644
# We don't know what the PID of the process was, so let's look at all core
610645
# files whose name matches core.NUMBER
611646
for f in core.*; do
612-
[[ $f =~ core.[0-9]+ ]] && print_info_from_core_file "$f" $CORE_ROOT/"corerun" && copy_core_file_to_temp_location "$f" && rm "$f"
647+
[[ $f =~ core.[0-9]+ ]] && print_info_from_core_file "$f" $CORE_ROOT/"corerun" && preserve_core_file "$f" && rm "$f"
613648
done
614649
elif [ -f core ]; then
615650
print_info_from_core_file "core" $CORE_ROOT/"corerun"
616-
copy_core_file_to_temp_location "core"
651+
preserve_core_file "core"
617652
rm "core"
618653
fi
619654
}

0 commit comments

Comments
 (0)