Skip to content

Commit

Permalink
[reboot] clear warm boot files when reboot is requested (#373)
Browse files Browse the repository at this point in the history
* [reboot] clear warm boot files when reboot is requested

Both warm/fast reboot are invoking /sbin/reboot directly.

If user invoked 'reboot', one scenario could be that user tried to issue
either fast or warm reboot and failed to complete. User then tries to
recover the system with a cold reboot.

In this scenario, particularly after warm-reboot request failed, we should
remove db backup files, so that the system will come up and perform a cold
recovery.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>

* [clean up] rename warm boot backup file config_db.json

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
  • Loading branch information
yxieca authored Nov 9, 2018
1 parent 904a51c commit 200b47f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/reboot
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ function stop_sonic_services()
sleep 3
}

function clear_warm_boot()
{
# If reboot is requested, make sure the outstanding warm-boot is cleared
# So the system will come up from a cold boot.
WARM_DIR="/host/warmboot"
TIMESTAMP=`date +%Y%m%d-%H%M%S`
if [[ -f ${WARM_DIR}/config_db.json ]]; then
mv -f ${WARM_DIR}/config_db.json ${WARM_DIR}/config_db-${TIMESTAMP}.json
fi
}

# Exit if not superuser
if [[ "$EUID" -ne 0 ]]; then
echo "This command must be run as root" >&2
Expand All @@ -23,6 +34,8 @@ fi
# Stop SONiC services gracefully.
stop_sonic_services

clear_warm_boot

# Update the reboot cause file to reflect that user issued 'reboot' command
# Upon next boot, the contents of this file will be used to determine the
# cause of the previous reboot
Expand Down

0 comments on commit 200b47f

Please sign in to comment.