Skip to content

Commit

Permalink
[generate_dump] Fix for symlinks in collect_mellanox_dfw_dumps()
Browse files Browse the repository at this point in the history
Signed-off-by: vadymhlushko-mlnx <vadymh@nvidia.com>
  • Loading branch information
vadymhlushko-mlnx committed Feb 1, 2023
1 parent c8940ad commit 8a8668c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions scripts/generate_dump
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ save_platform_info() {
# filename: the full path of the file to save
# base_dir: the directory in $TARDIR/ to stage the file
# do_gzip: (OPTIONAL) true or false. Should the output be gzipped
# do_tar_append: (OPTIONAL) true or false. Should the output be added to final tar archive
# Returns:
# None
###############################################################################
Expand All @@ -930,13 +931,16 @@ save_file() {
local orig_path=$1
local supp_dir=$2
local gz_path="$TARDIR/$supp_dir/$(basename $orig_path)"
local tar_path="${BASE}/$supp_dir/$(basename $orig_path)"
local do_gzip=${3:-true}
local do_tar_append=${4:-false}
if [ ! -d "$TARDIR/$supp_dir" ]; then
$MKDIR $V -p "$TARDIR/$supp_dir"
fi

if $do_gzip; then
gz_path="${gz_path}.gz"
tar_path="${tar_path}.gz"
if $NOOP; then
echo "gzip -c $orig_path > $gz_path"
else
Expand All @@ -950,6 +954,12 @@ save_file() {
fi
fi

if $do_tar_append; then
($TAR $V -rhf $TARFILE -C $DUMPDIR "$tar_path" \
|| abort "${EXT_PROCFS_SAVE_FAILED}" "tar append operation failed. Aborting to prevent data loss.") \
&& $RM $V -f "$gz_path"
fi

end_t=$(date +%s%3N)
echo "[ save_file:$orig_path] : $(($end_t-$start_t)) msec" >> $TECHSUPPORT_TIME_INFO
}
Expand Down Expand Up @@ -1134,9 +1144,9 @@ collect_mellanox_dfw_dumps() {
${CMD_PREFIX}save_symlink ${file} sai_sdk_dump log
else
if [ ! -z "${file##*.gz}" ]; then
${CMD_PREFIX}save_file ${file} sai_sdk_dump true
${CMD_PREFIX}save_file ${file} sai_sdk_dump true true
else
${CMD_PREFIX}save_file ${file} sai_sdk_dump false
${CMD_PREFIX}save_file ${file} sai_sdk_dump false true
fi
fi
done
Expand Down Expand Up @@ -1697,7 +1707,7 @@ main() {
$RM $V -rf $TARDIR/etc/alternatives $TARDIR/etc/passwd* \
$TARDIR/etc/shadow* $TARDIR/etc/group* $TARDIR/etc/gshadow* \
$TARDIR/etc/ssh* $TARDIR/etc/mlnx $TARDIR/etc/mft \
$TARDIR/etc/ssl/certs/ $TARDIR/etc/ssl/private/*
$TARDIR/etc/ssl/certs/* $TARDIR/etc/ssl/private/*
rm_list=$(find -L $TARDIR -type f \( -iname \*.cer -o -iname \*.crt -o \
-iname \*.pem -o -iname \*.key -o -iname \*snmpd.conf\* -o -iname \*get_creds\* \))
if [ ! -z "$rm_list" ]
Expand All @@ -1710,6 +1720,8 @@ main() {
save_warmboot_files &
wait

save_to_tar

if [[ "$asic" = "mellanox" ]]; then
collect_mellanox_dfw_dumps
fi
Expand All @@ -1722,9 +1734,7 @@ main() {
###############################################################################
finalize() {
# Save techsupport timing profile info
save_file $TECHSUPPORT_TIME_INFO log false

save_to_tar
save_file $TECHSUPPORT_TIME_INFO log false true

if $DO_COMPRESS; then
RC=0
Expand Down

0 comments on commit 8a8668c

Please sign in to comment.