Skip to content

Commit 4a36e94

Browse files
[generate_dump] Fix for symlinks in collect_mellanox_dfw_dumps()
Signed-off-by: vadymhlushko-mlnx <[email protected]>
1 parent 34cd457 commit 4a36e94

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

scripts/generate_dump

+18-8
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ save_platform_info() {
867867
# filename: the full path of the file to save
868868
# base_dir: the directory in $TARDIR/ to stage the file
869869
# do_gzip: (OPTIONAL) true or false. Should the output be gzipped
870+
# do_tar_append: (OPTIONAL) true or false. Should the output be added to final tar archive
870871
# Returns:
871872
# None
872873
###############################################################################
@@ -877,13 +878,16 @@ save_file() {
877878
local orig_path=$1
878879
local supp_dir=$2
879880
local gz_path="$TARDIR/$supp_dir/$(basename $orig_path)"
881+
local tar_path="${BASE}/$supp_dir/$(basename $orig_path)"
880882
local do_gzip=${3:-true}
883+
local do_tar_append=${4:-false}
881884
if [ ! -d "$TARDIR/$supp_dir" ]; then
882885
$MKDIR $V -p "$TARDIR/$supp_dir"
883886
fi
884887

885888
if $do_gzip; then
886889
gz_path="${gz_path}.gz"
890+
tar_path="${tar_path}.gz"
887891
if $NOOP; then
888892
echo "gzip -c $orig_path > $gz_path"
889893
else
@@ -897,6 +901,12 @@ save_file() {
897901
fi
898902
fi
899903

904+
if $do_tar_append; then
905+
($TAR $V -rhf $TARFILE -C $DUMPDIR "$tar_path" \
906+
|| abort "${EXT_PROCFS_SAVE_FAILED}" "tar append operation failed. Aborting to prevent data loss.") \
907+
&& $RM $V -f "$gz_path"
908+
fi
909+
900910
end_t=$(date +%s%3N)
901911
echo "[ save_file:$orig_path] : $(($end_t-$start_t)) msec" >> $TECHSUPPORT_TIME_INFO
902912
}
@@ -1086,9 +1096,9 @@ collect_mellanox_dfw_dumps() {
10861096
${CMD_PREFIX}save_symlink ${file} sai_sdk_dump log
10871097
else
10881098
if [ ! -z "${file##*.gz}" ]; then
1089-
${CMD_PREFIX}save_file ${file} sai_sdk_dump true
1099+
${CMD_PREFIX}save_file ${file} sai_sdk_dump true true
10901100
else
1091-
${CMD_PREFIX}save_file ${file} sai_sdk_dump false
1101+
${CMD_PREFIX}save_file ${file} sai_sdk_dump false true
10921102
fi
10931103
fi
10941104
done
@@ -1377,9 +1387,9 @@ save_sai_failure_dump(){
13771387
${CMD_PREFIX}save_symlink ${file} sai_failure_dump log
13781388
else
13791389
if [ ! -z "${file##*.gz}" ]; then
1380-
${CMD_PREFIX}save_file ${file} sai_failure_dump true
1390+
${CMD_PREFIX}save_file ${file} sai_failure_dump true true
13811391
else
1382-
${CMD_PREFIX}save_file ${file} sai_failure_dump false
1392+
${CMD_PREFIX}save_file ${file} sai_failure_dump false true
13831393
fi
13841394
fi
13851395
#Clean up the file once its part of tech support
@@ -1643,7 +1653,7 @@ main() {
16431653
$RM $V -rf $TARDIR/etc/alternatives $TARDIR/etc/passwd* \
16441654
$TARDIR/etc/shadow* $TARDIR/etc/group* $TARDIR/etc/gshadow* \
16451655
$TARDIR/etc/ssh* $TARDIR/etc/mlnx $TARDIR/etc/mft \
1646-
$TARDIR/etc/ssl/certs/ $TARDIR/etc/ssl/private/*
1656+
$TARDIR/etc/ssl/certs/* $TARDIR/etc/ssl/private/*
16471657
rm_list=$(find -L $TARDIR -type f \( -iname \*.cer -o -iname \*.crt -o \
16481658
-iname \*.pem -o -iname \*.key -o -iname \*snmpd.conf\* -o -iname \*get_creds\* \))
16491659
if [ ! -z "$rm_list" ]
@@ -1656,6 +1666,8 @@ main() {
16561666
save_warmboot_files &
16571667
wait
16581668

1669+
save_to_tar
1670+
16591671
save_sai_failure_dump
16601672

16611673
if [[ "$asic" = "mellanox" ]]; then
@@ -1670,9 +1682,7 @@ main() {
16701682
###############################################################################
16711683
finalize() {
16721684
# Save techsupport timing profile info
1673-
save_file $TECHSUPPORT_TIME_INFO log false
1674-
1675-
save_to_tar
1685+
save_file $TECHSUPPORT_TIME_INFO log false true
16761686

16771687
if $DO_COMPRESS; then
16781688
RC=0

0 commit comments

Comments
 (0)