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 6, 2023
1 parent 3504fdc commit 2450c48
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/generate_dump
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ save_saidump() {
# Returns:
# None
###############################################################################
save_saidump_by_save_cmd() {
save_saidump_by_redis_save_cmd() {
trap 'handle_error $? $LINENO' ERR
if [[ ( "$NUM_ASICS" == 1 ) ]] ; then
save_cmd "saidump.sh" "saidump"
Expand Down Expand Up @@ -1813,7 +1813,7 @@ main() {
if [[ "$device_type" != "SpineRouter" ]]; then
save_saidump
else
save_saidump_by_save_cmd
save_saidump_by_redis_save_cmd
fi

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

0 comments on commit 2450c48

Please sign in to comment.