Skip to content

Commit 4a3c5e4

Browse files
authored
[202205] Fast reboot finalizer 202205 (#14143)
* Finalize fast-reboot in warmboot finalizer * update fast/warm-reboot finalizer * support compatibility for fast-reboot from previous versions (prior 202205) * advance pointers: sairedis, utilities
1 parent 95047bd commit 4a3c5e4

10 files changed

Lines changed: 66 additions & 27 deletions

File tree

files/image_config/ntp/ntp-config.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ reboot_type='cold'
88
function get_database_reboot_type()
99
{
1010
SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
11-
SYSTEM_FAST_START=`sonic-db-cli STATE_DB get "FAST_REBOOT|system"`
11+
SYSTEM_FAST_START=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
1212

1313
if [[ x"${SYSTEM_WARM_START}" == x"true" ]]; then
1414
reboot_type='warm'
15-
elif [[ x"${SYSTEM_FAST_START}" == x"1" ]]; then
15+
elif [[ x"${SYSTEM_FAST_START}" == x"true" ]]; then
1616
reboot_type='fast'
1717
fi
1818
}

files/image_config/warmboot-finalizer/finalize-warmboot.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ function check_warm_boot()
5252
WARM_BOOT=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
5353
}
5454

55+
function check_fast_reboot()
56+
{
57+
debug "Checking if fast-reboot is enabled..."
58+
FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
59+
if [[ x"${FAST_REBOOT}" == x"true" ]]; then
60+
debug "Fast-reboot is enabled..."
61+
else
62+
debug "Fast-reboot is disabled..."
63+
fi
64+
}
65+
5566

5667
function wait_for_database_service()
5768
{
@@ -97,6 +108,12 @@ function finalize_warm_boot()
97108
sudo config warm_restart disable
98109
}
99110

111+
function finalize_fast_reboot()
112+
{
113+
debug "Finalizing fast-reboot..."
114+
sonic-db-cli STATE_DB hset "FAST_RESTART_ENABLE_TABLE|system" "enable" "false" &>/dev/null
115+
}
116+
100117
function stop_control_plane_assistant()
101118
{
102119
if [[ -x ${ASSISTANT_SCRIPT} ]]; then
@@ -118,14 +135,20 @@ function restore_counters_folder()
118135

119136
wait_for_database_service
120137

138+
check_fast_reboot
121139
check_warm_boot
122140

123141
if [[ x"${WARM_BOOT}" != x"true" ]]; then
124142
debug "warmboot is not enabled ..."
125-
exit 0
143+
if [[ x"${FAST_REBOOT}" != x"true" ]]; then
144+
debug "fastboot is not enabled ..."
145+
exit 0
146+
fi
126147
fi
127148

128-
restore_counters_folder
149+
if [[ (x"${WARM_BOOT}" == x"true") && (x"${FAST_REBOOT}" != x"true") ]]; then
150+
restore_counters_folder
151+
fi
129152

130153
get_component_list
131154

@@ -142,14 +165,22 @@ for i in `seq 60`; do
142165
sleep 5
143166
done
144167

145-
stop_control_plane_assistant
168+
if [[ (x"${WARM_BOOT}" == x"true") && (x"${FAST_REBOOT}" != x"true") ]]; then
169+
stop_control_plane_assistant
170+
fi
146171

147172
# Save DB after stopped control plane assistant to avoid extra entries
148-
debug "Save in-memory database after warm reboot ..."
173+
debug "Save in-memory database after warm/fast reboot ..."
149174
config save -y
150175

151176
if [[ -n "${list}" ]]; then
152177
debug "Some components didn't finish reconcile: ${list} ..."
153178
fi
154179

155-
finalize_warm_boot
180+
if [ x"${FAST_REBOOT}" == x"true" ]; then
181+
finalize_fast_reboot
182+
fi
183+
184+
if [ x"${WARM_BOOT}" == x"true" ]; then
185+
finalize_warm_boot
186+
fi

files/scripts/bgp.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ function validate_restore_count()
3030

3131
function check_fast_boot ()
3232
{
33-
if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
33+
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
34+
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
3435
FAST_BOOT="true"
3536
else
3637
FAST_BOOT="false"

files/scripts/service_mgmt.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function check_warm_boot()
1919

2020
function check_fast_boot ()
2121
{
22-
if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
22+
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
23+
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
2324
FAST_BOOT="true"
2425
else
2526
FAST_BOOT="false"

files/scripts/swss.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ function check_warm_boot()
6060

6161
function check_fast_boot()
6262
{
63-
if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
63+
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
64+
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
6465
FAST_BOOT="true"
6566
else
6667
FAST_BOOT="false"
@@ -284,8 +285,8 @@ stop() {
284285
# encountered error, e.g. syncd crashed. And swss needs to
285286
# be restarted.
286287
if [[ x"$FAST_BOOT" != x"true" ]]; then
287-
debug "Clearing FAST_REBOOT flag..."
288-
clean_up_tables STATE_DB "'FAST_REBOOT*'"
288+
debug "Clearing FAST_RESTART_ENABLE_TABLE flag..."
289+
sonic-db-cli STATE_DB hset "FAST_RESTART_ENABLE_TABLE|system" "enable" "false"
289290
fi
290291
# Unlock has to happen before reaching out to peer service
291292
unlock_service_state_change

files/scripts/syncd_common.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ function check_warm_boot()
5050

5151
function check_fast_boot()
5252
{
53-
if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
53+
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
54+
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
5455
FAST_BOOT="true"
5556
else
5657
FAST_BOOT="false"
@@ -82,7 +83,8 @@ function getBootType()
8283
;;
8384
*SONIC_BOOT_TYPE=fast*|*fast-reboot*)
8485
# check that the key exists
85-
if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
86+
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
87+
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
8688
TYPE='fast'
8789
else
8890
TYPE='cold'

files/scripts/teamd.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ function validate_restore_count()
3232

3333
function check_fast_boot ()
3434
{
35-
if [[ $($SONIC_DB_CLI STATE_DB GET "FAST_REBOOT|system") == "1" ]]; then
35+
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
36+
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
3637
FAST_BOOT="true"
3738
else
3839
FAST_BOOT="false"

src/sonic-py-common/sonic_py_common/device_info.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -669,14 +669,16 @@ def is_warm_restart_enabled(container_name):
669669

670670
# Check if System fast reboot is enabled.
671671
def is_fast_reboot_enabled():
672-
fb_system_state = 0
673-
cmd = 'sonic-db-cli STATE_DB get "FAST_REBOOT|system"'
674-
proc = subprocess.Popen(cmd, shell=True, universal_newlines=True, stdout=subprocess.PIPE)
675-
(stdout, stderr) = proc.communicate()
676-
677-
if proc.returncode != 0:
678-
log.log_error("Error running command '{}'".format(cmd))
679-
elif stdout:
680-
fb_system_state = stdout.rstrip('\n')
672+
state_db = SonicV2Connector(host='127.0.0.1')
673+
state_db.connect(state_db.STATE_DB, False)
674+
675+
TABLE_NAME_SEPARATOR = '|'
676+
prefix = 'FAST_RESTART_ENABLE_TABLE' + TABLE_NAME_SEPARATOR
677+
678+
# Get the system warm reboot enable state
679+
_hash = '{}{}'.format(prefix, 'system')
680+
fb_system_state = state_db.get(state_db.STATE_DB, _hash, "enable")
681+
fb_enable_state = True if fb_system_state == "true" else False
681682

682-
return fb_system_state
683+
state_db.close(state_db.STATE_DB)
684+
return fb_enable_state

src/sonic-sairedis

0 commit comments

Comments
 (0)