Skip to content

Commit

Permalink
* [saidump]
Browse files Browse the repository at this point in the history
    •       Saidump for DNX-SAI sonic-net/sonic-buildimage#13561

    Solution and modification:
    To use the redis-db SAVE option to save the snapshot of DB each time and recover later, instead of looping through each entry in the table and saving it.

    (1) Updated sonic-buildimage/build_debian.sh, to install Python library rdbtools into the host.
    (2) Updated sonic-buildimage/src/sonic-sairedis/saidump/saidump.cpp, add a new option -r, which updates the rdbtools's output-JSON files' format.
    (3) Add a new script file: files/scripts/saidump.sh, to do the below steps
      For each ASIC0, such as ASIC0,

      1. Save the Redis data.
      sudo sonic-db-cli -n asic$1 SAVE > /dev/null

      2. Move dump files to /var/run/redisX/
      docker exec database$1 sh -c "mv /var/lib/redis/dump.rdb /var/run/redis$1/"

      3. Run rdb command to convert the dump files into JSON files
      sudo python /usr/local/bin/rdb --command json  /var/run/redis$1/dump.rdb | sudo tee /var/run/redis$1/dump.json > /dev/null

      4. Run saidump -r to update the JSON files' format as same as the saidump before. Then we can get the saidump result in standard output.
      docker exec syncd$1 sh -c "saidump -r /var/run/redis$1/dump.json"

      5. clear
      sudo rm -f /var/run/redis$1/dump.rdb
      sudo rm -f /var/run/redis$1/dump.json

    (4) Update sonic-buildimage/src/sonic-utilities/scripts/generate_dump, replace saidump with saidump.sh
  • Loading branch information
JunhongMao committed Sep 5, 2023
1 parent 5ecb3c1 commit 3504fdc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/generate_dump
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,27 @@ save_redis() {
# None
###############################################################################
save_saidump() {
trap 'handle_error $? $LINENO' ERR
if [[ ( "$NUM_ASICS" == 1 ) ]] ; then
save_cmd "docker exec syncd saidump" "saidump"
else
for (( i=0; i<$NUM_ASICS; i++ ))
do
save_cmd "docker exec syncd$i saidump" "saidump$i"
done
fi
}

###############################################################################
# SAI DUMP from syncd by Redis Save command
# Globals:
# NUM_ASICS
# Arguments:
# None
# Returns:
# None
###############################################################################
save_saidump_by_save_cmd() {
trap 'handle_error $? $LINENO' ERR
if [[ ( "$NUM_ASICS" == 1 ) ]] ; then
save_cmd "saidump.sh" "saidump"
Expand Down Expand Up @@ -1791,6 +1812,8 @@ main() {

if [[ "$device_type" != "SpineRouter" ]]; then
save_saidump
else
save_saidump_by_save_cmd
fi

if [ "$asic" = "barefoot" ]; then
Expand Down

0 comments on commit 3504fdc

Please sign in to comment.