Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove timer from FAST_REBOOT STATE_DB entry and use finalizer #2621

Merged
merged 13 commits into from
Mar 10, 2023
20 changes: 18 additions & 2 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, namespace, socket=None):
none-zero values.
build: sequentially increase within a minor version domain.
"""
self.CURRENT_VERSION = 'version_4_0_0'
self.CURRENT_VERSION = 'version_4_0_1'
arfeigin marked this conversation as resolved.
Show resolved Hide resolved

self.TABLE_NAME = 'VERSIONS'
self.TABLE_KEY = 'DATABASE'
Expand Down Expand Up @@ -850,9 +850,25 @@ def version_3_0_6(self):
def version_4_0_0(self):
"""
Version 4_0_0.
This is the latest version for master branch
"""
log.log_info('Handling version_4_0_0')
# Update state-db fast-reboot entry to enable if set to enable fast-reboot finalizer when using upgrade with fast-reboot
# since upgrading from previous version FAST_REBOOT table will be deleted when the timer will expire.
fastreboot_state = self.stateDB.get(self.stateDB.STATE_DB, 'FAST_REBOOT|system', '1')
if fastreboot_state == 'true':
arfeigin marked this conversation as resolved.
Show resolved Hide resolved
enable_state = 'enable'
else:
enable_state = 'disable'
self.stateDB.set(self.stateDB.STATE_DB, 'FAST_RESTART_ENABLE_TABLE', 'system', enable_state)
self.set_version('version_4_0_1')
return 'version_4_0_1'

def version_4_0_1(self):
"""
Version 4_0_1.
This is the latest version for master branch
"""
log.log_info('Handling version_4_0_1')
return None

def get_version(self):
Expand Down
6 changes: 3 additions & 3 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function clear_boot()

#clear_fast_boot
if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
sonic-db-cli STATE_DB DEL "FAST_REBOOT|system" &>/dev/null || /bin/true
sonic-db-cli STATE_DB SET "FAST_RESTART_ENABLE_TABLE|system" "disable" &>/dev/null || /bin/true
fi
}

Expand Down Expand Up @@ -265,7 +265,7 @@ function backup_database()
and not string.match(k, 'WARM_RESTART_ENABLE_TABLE|') \
and not string.match(k, 'VXLAN_TUNNEL_TABLE|') \
and not string.match(k, 'BUFFER_MAX_PARAM_TABLE|') \
and not string.match(k, 'FAST_REBOOT|') then
and not string.match(k, 'FAST_RESTART_ENABLE_TABLE|') then
redis.call('del', k)
end
end
Expand Down Expand Up @@ -532,7 +532,7 @@ case "$REBOOT_TYPE" in
check_warm_restart_in_progress
BOOT_TYPE_ARG=$REBOOT_TYPE
trap clear_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "210" &>/dev/null
sonic-db-cli STATE_DB SET "FAST_RESTART_ENABLE_TABLE|system" "enable" &>/dev/null
config warm_restart enable system
;;
"warm-reboot")
Expand Down
3 changes: 2 additions & 1 deletion sonic-utilities-data/templates/service_mgmt.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function check_warm_boot()

function check_fast_boot()
{
if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB GET "FAST_RESTART_ENABLE_TABLE|system"`
if [[ ${SYSTEM_FAST_REBOOT} == "enable" ]]; then
FAST_BOOT="true"
else
FAST_BOOT="false"
Expand Down