Skip to content

Commit

Permalink
fix error: interface counters is mismatch after warm-reboot (sonic-ne…
Browse files Browse the repository at this point in the history
…t#5346)

- Why I did it
There is a issue for counters after warm-reboot:
If I clear counters by command "sonic-clear counters", then execute 'warm-reboot' and whenSONiC is restart, the counters showed with command "show interface counters" is still old counters before "sonic-clear". It is not the right counters because the counters file in '/tmp' is lost in warm-reboot process.

- How I did it
I fixed it by saving '/tmp/portstat-0' folders in '/host/' before executing 'warm-reboot' (in pull request sonic-net/sonic-utilities#1099 ), and restore the counters folders back to '/tmp/' after warm-reboot process is finished.

- How to verify it

Clear counters by command 'sonic-clear'
sonic-clear counters
sonic-clear dropcounters
sonic-clear pfccounters
sonic-clear queuecounters
sonic-clear rifcounters
Execute 'warm-reboot'
Use command ‘show interface counters’ to see if the counters is right.
  • Loading branch information
JiangboHe authored and santhosh-kt committed Feb 25, 2021
1 parent ef1ba10 commit 80d5fe1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions files/image_config/warmboot-finalizer/finalize-warmboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ function stop_control_plane_assistant()
fi
}

function restore_counters_folder()
{
debug "Restoring counters folder after warmboot..."

modules=("portstat-0" "dropstat" "pfcstat-0" "queuestat-0" "intfstat-0")
for module in ${modules[@]}
do
statfile="/host/counters/$module"
if [[ -d $statfile ]]; then
mv $statfile /tmp/
fi
done
}


wait_for_database_service

Expand All @@ -86,6 +100,8 @@ if [[ x"${WARM_BOOT}" != x"true" ]]; then
exit 0
fi

restore_counters_folder

list=${COMP_LIST}

# Wait up to 5 minutes
Expand Down

0 comments on commit 80d5fe1

Please sign in to comment.