Skip to content

Commit bac02bc

Browse files
[generate_dump] Fix for symlinks in collect_mellanox_dfw_dumps() and save_sai_failure_dump()
Signed-off-by: vadymhlushko-mlnx <[email protected]>
1 parent 97b4c12 commit bac02bc

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

scripts/generate_dump

+16-6
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ save_platform_info() {
920920
# filename: the full path of the file to save
921921
# base_dir: the directory in $TARDIR/ to stage the file
922922
# do_gzip: (OPTIONAL) true or false. Should the output be gzipped
923+
# do_tar_append: (OPTIONAL) true or false. Should the output be added to final tar archive
923924
# Returns:
924925
# None
925926
###############################################################################
@@ -930,13 +931,16 @@ save_file() {
930931
local orig_path=$1
931932
local supp_dir=$2
932933
local gz_path="$TARDIR/$supp_dir/$(basename $orig_path)"
934+
local tar_path="${BASE}/$supp_dir/$(basename $orig_path)"
933935
local do_gzip=${3:-true}
936+
local do_tar_append=${4:-false}
934937
if [ ! -d "$TARDIR/$supp_dir" ]; then
935938
$MKDIR $V -p "$TARDIR/$supp_dir"
936939
fi
937940

938941
if $do_gzip; then
939942
gz_path="${gz_path}.gz"
943+
tar_path="${tar_path}.gz"
940944
if $NOOP; then
941945
echo "gzip -c $orig_path > $gz_path"
942946
else
@@ -950,6 +954,12 @@ save_file() {
950954
fi
951955
fi
952956

957+
if $do_tar_append; then
958+
($TAR $V -rhf $TARFILE -C $DUMPDIR "$tar_path" \
959+
|| abort "${EXT_PROCFS_SAVE_FAILED}" "tar append operation failed. Aborting to prevent data loss.") \
960+
&& $RM $V -f "$gz_path"
961+
fi
962+
953963
end_t=$(date +%s%3N)
954964
echo "[ save_file:$orig_path] : $(($end_t-$start_t)) msec" >> $TECHSUPPORT_TIME_INFO
955965
}
@@ -1139,9 +1149,9 @@ collect_mellanox_dfw_dumps() {
11391149
${CMD_PREFIX}save_symlink ${file} sai_sdk_dump log
11401150
else
11411151
if [ ! -z "${file##*.gz}" ]; then
1142-
${CMD_PREFIX}save_file ${file} sai_sdk_dump true
1152+
${CMD_PREFIX}save_file ${file} sai_sdk_dump true true
11431153
else
1144-
${CMD_PREFIX}save_file ${file} sai_sdk_dump false
1154+
${CMD_PREFIX}save_file ${file} sai_sdk_dump false true
11451155
fi
11461156
fi
11471157
done
@@ -1734,7 +1744,7 @@ main() {
17341744
$RM $V -rf $TARDIR/etc/alternatives $TARDIR/etc/passwd* \
17351745
$TARDIR/etc/shadow* $TARDIR/etc/group* $TARDIR/etc/gshadow* \
17361746
$TARDIR/etc/ssh* $TARDIR/etc/mlnx $TARDIR/etc/mft \
1737-
$TARDIR/etc/ssl/certs/ $TARDIR/etc/ssl/private/*
1747+
$TARDIR/etc/ssl/certs/* $TARDIR/etc/ssl/private/*
17381748
rm_list=$(find -L $TARDIR -type f \( -iname \*.cer -o -iname \*.crt -o \
17391749
-iname \*.pem -o -iname \*.key -o -iname \*snmpd.conf\* -o -iname \*get_creds\* \))
17401750
if [ ! -z "$rm_list" ]
@@ -1747,6 +1757,8 @@ main() {
17471757
save_warmboot_files &
17481758
wait
17491759

1760+
save_to_tar
1761+
17501762
save_sai_failure_dump
17511763

17521764
if [[ "$asic" = "mellanox" ]]; then
@@ -1761,9 +1773,7 @@ main() {
17611773
###############################################################################
17621774
finalize() {
17631775
# Save techsupport timing profile info
1764-
save_file $TECHSUPPORT_TIME_INFO log false
1765-
1766-
save_to_tar
1776+
save_file $TECHSUPPORT_TIME_INFO log false true
17671777

17681778
if $DO_COMPRESS; then
17691779
RC=0

0 commit comments

Comments
 (0)