Skip to content

Commit 8a8668c

Browse files
[generate_dump] Fix for symlinks in collect_mellanox_dfw_dumps()
Signed-off-by: vadymhlushko-mlnx <[email protected]>
1 parent c8940ad commit 8a8668c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

scripts/generate_dump

Lines changed: 16 additions & 6 deletions
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
}
@@ -1134,9 +1144,9 @@ collect_mellanox_dfw_dumps() {
11341144
${CMD_PREFIX}save_symlink ${file} sai_sdk_dump log
11351145
else
11361146
if [ ! -z "${file##*.gz}" ]; then
1137-
${CMD_PREFIX}save_file ${file} sai_sdk_dump true
1147+
${CMD_PREFIX}save_file ${file} sai_sdk_dump true true
11381148
else
1139-
${CMD_PREFIX}save_file ${file} sai_sdk_dump false
1149+
${CMD_PREFIX}save_file ${file} sai_sdk_dump false true
11401150
fi
11411151
fi
11421152
done
@@ -1697,7 +1707,7 @@ main() {
16971707
$RM $V -rf $TARDIR/etc/alternatives $TARDIR/etc/passwd* \
16981708
$TARDIR/etc/shadow* $TARDIR/etc/group* $TARDIR/etc/gshadow* \
16991709
$TARDIR/etc/ssh* $TARDIR/etc/mlnx $TARDIR/etc/mft \
1700-
$TARDIR/etc/ssl/certs/ $TARDIR/etc/ssl/private/*
1710+
$TARDIR/etc/ssl/certs/* $TARDIR/etc/ssl/private/*
17011711
rm_list=$(find -L $TARDIR -type f \( -iname \*.cer -o -iname \*.crt -o \
17021712
-iname \*.pem -o -iname \*.key -o -iname \*snmpd.conf\* -o -iname \*get_creds\* \))
17031713
if [ ! -z "$rm_list" ]
@@ -1710,6 +1720,8 @@ main() {
17101720
save_warmboot_files &
17111721
wait
17121722

1723+
save_to_tar
1724+
17131725
if [[ "$asic" = "mellanox" ]]; then
17141726
collect_mellanox_dfw_dumps
17151727
fi
@@ -1722,9 +1734,7 @@ main() {
17221734
###############################################################################
17231735
finalize() {
17241736
# Save techsupport timing profile info
1725-
save_file $TECHSUPPORT_TIME_INFO log false
1726-
1727-
save_to_tar
1737+
save_file $TECHSUPPORT_TIME_INFO log false true
17281738

17291739
if $DO_COMPRESS; then
17301740
RC=0

0 commit comments

Comments
 (0)