@@ -40,8 +40,6 @@ EXIT_FILE_SYSTEM_FULL=3
40
40
EXIT_NEXT_IMAGE_NOT_EXISTS=4
41
41
EXIT_ORCHAGENT_SHUTDOWN=10
42
42
EXIT_SYNCD_SHUTDOWN=11
43
- EXIT_FAST_REBOOT_DUMP_FAILURE=12
44
- EXIT_FILTER_FDB_ENTRIES_FAILURE=13
45
43
EXIT_COUNTERPOLL_DELAY_FAILURE=14
46
44
EXIT_DB_INTEGRITY_FAILURE=15
47
45
EXIT_NO_CONTROL_PLANE_ASSISTANT=20
@@ -125,41 +123,36 @@ function parseOptions()
125
123
done
126
124
}
127
125
128
- function common_clear ()
126
+ function clear_boot ()
129
127
{
128
+ # common_clear
130
129
debug " ${REBOOT_TYPE} failure ($? ) cleanup ..."
131
130
132
131
/sbin/kexec -u || /bin/true
133
132
134
133
teardown_control_plane_assistant
135
- }
136
-
137
- function clear_fast_boot()
138
- {
139
- common_clear
140
-
141
- sonic-db-cli STATE_DB DEL " FAST_REBOOT|system" & > /dev/null || /bin/true
142
- }
143
-
144
- function clear_warm_boot()
145
- {
146
- common_clear
147
134
135
+ # clear_warm_boot
148
136
result=$( timeout 10s config warm_restart disable; res=$? ; if [[ $res == 124 ]]; then echo timeout; else echo " code ($res )" ; fi) || /bin/true
149
137
debug " Cancel warm-reboot: ${result} "
150
138
151
139
TIMESTAMP=$( date +%Y%m%d-%H%M%S)
152
140
if [[ -f ${WARM_DIR} /${REDIS_FILE} ]]; then
153
141
mv -f ${WARM_DIR} /${REDIS_FILE} ${WARM_DIR} /${REDIS_FILE} .${TIMESTAMP} || /bin/true
154
142
fi
143
+
144
+ # clear_fast_boot
145
+ if [[ " $REBOOT_TYPE " = " fast-reboot" ]]; then
146
+ sonic-db-cli STATE_DB DEL " FAST_REBOOT|system" & > /dev/null || /bin/true
147
+ fi
155
148
}
156
149
157
150
function init_warm_reboot_states()
158
151
{
159
152
# If the current running instance was booted up with warm reboot. Then
160
153
# the current DB contents will likely mark warm reboot is done.
161
154
# Clear these states so that the next boot up image won't get confused.
162
- if [[ " $REBOOT_TYPE " = " warm-reboot" || " $REBOOT_TYPE " = " fastfast-reboot" ]]; then
155
+ if [[ " $REBOOT_TYPE " = " warm-reboot" || " $REBOOT_TYPE " = " fastfast-reboot" || " $REBOOT_TYPE " = " fast-reboot " ]]; then
163
156
sonic-db-cli STATE_DB eval "
164
157
for _, key in ipairs(redis.call('keys', 'WARM_RESTART_TABLE|*')) do
165
158
redis.call('hdel', key, 'state')
@@ -266,7 +259,8 @@ function backup_database()
266
259
and not string.match(k, 'FG_ROUTE_TABLE|') \
267
260
and not string.match(k, 'WARM_RESTART_ENABLE_TABLE|') \
268
261
and not string.match(k, 'VXLAN_TUNNEL_TABLE|') \
269
- and not string.match(k, 'BUFFER_MAX_PARAM_TABLE|') then
262
+ and not string.match(k, 'BUFFER_MAX_PARAM_TABLE|') \
263
+ and not string.match(k, 'FAST_REBOOT|') then
270
264
redis.call('del', k)
271
265
end
272
266
end
@@ -371,7 +365,7 @@ function check_docker_exec()
371
365
372
366
function check_db_integrity()
373
367
{
374
- if [[ " $REBOOT_TYPE " = " warm-reboot" || " $REBOOT_TYPE " = " fastfast-reboot" ]]; then
368
+ if [[ " $REBOOT_TYPE " = " warm-reboot" || " $REBOOT_TYPE " = " fastfast-reboot" || " $REBOOT_TYPE " = " fast-reboot " ]]; then
375
369
CHECK_DB_INTEGRITY=0
376
370
/usr/local/bin/check_db_integrity.py || CHECK_DB_INTEGRITY=$?
377
371
if [[ CHECK_DB_INTEGRITY -ne 0 ]]; then
@@ -454,7 +448,6 @@ function unload_kernel()
454
448
function save_counters_folder() {
455
449
if [[ " $REBOOT_TYPE " = " warm-reboot" ]]; then
456
450
debug " Saving counters folder before warmboot..."
457
-
458
451
counters_folder=" /host/counters"
459
452
if [[ ! -d $counters_folder ]]; then
460
453
mkdir $counters_folder
@@ -523,9 +516,11 @@ sonic_asic_type=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
523
516
BOOT_TYPE_ARG=" cold"
524
517
case " $REBOOT_TYPE " in
525
518
" fast-reboot" )
519
+ check_warm_restart_in_progress
526
520
BOOT_TYPE_ARG=$REBOOT_TYPE
527
- trap clear_fast_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
521
+ trap clear_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
528
522
sonic-db-cli STATE_DB SET " FAST_REBOOT|system" " 1" " EX" " 180" & > /dev/null
523
+ config warm_restart enable system
529
524
;;
530
525
" warm-reboot" )
531
526
check_warm_restart_in_progress
@@ -538,7 +533,7 @@ case "$REBOOT_TYPE" in
538
533
else
539
534
BOOT_TYPE_ARG=" warm"
540
535
fi
541
- trap clear_warm_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
536
+ trap clear_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
542
537
config warm_restart enable system
543
538
;;
544
539
* )
@@ -596,34 +591,11 @@ else
596
591
load_kernel
597
592
fi
598
593
599
- if [[ " $REBOOT_TYPE " = " fast-reboot" ]]; then
600
- # Dump the ARP and FDB tables to files also as default routes for both IPv4 and IPv6
601
- # into /host/fast-reboot
602
- DUMP_DIR=/host/fast-reboot
603
- mkdir -p $DUMP_DIR
604
- FAST_REBOOT_DUMP_RC=0
605
- /usr/local/bin/fast-reboot-dump.py -t $DUMP_DIR || FAST_REBOOT_DUMP_RC=$?
606
- if [[ FAST_REBOOT_DUMP_RC -ne 0 ]]; then
607
- error " Failed to run fast-reboot-dump.py. Exit code: $FAST_REBOOT_DUMP_RC "
608
- unload_kernel
609
- exit " ${EXIT_FAST_REBOOT_DUMP_FAILURE} "
610
- fi
611
-
612
- FILTER_FDB_ENTRIES_RC=0
613
- # Filter FDB entries using MAC addresses from ARP table
614
- /usr/local/bin/filter_fdb_entries -f $DUMP_DIR /fdb.json -a $DUMP_DIR /arp.json -c $CONFIG_DB_FILE || FILTER_FDB_ENTRIES_RC=$?
615
- if [[ FILTER_FDB_ENTRIES_RC -ne 0 ]]; then
616
- error " Failed to filter FDb entries. Exit code: $FILTER_FDB_ENTRIES_RC "
617
- unload_kernel
618
- exit " ${EXIT_FILTER_FDB_ENTRIES_FAILURE} "
619
- fi
620
- fi
621
-
622
594
init_warm_reboot_states
623
595
624
596
setup_control_plane_assistant
625
597
626
- if [[ " $REBOOT_TYPE " = " warm-reboot" || " $REBOOT_TYPE " = " fastfast-reboot" ]]; then
598
+ if [[ " $REBOOT_TYPE " = " warm-reboot" || " $REBOOT_TYPE " = " fastfast-reboot" || " $REBOOT_TYPE " = " fast-reboot " ]]; then
627
599
# Freeze orchagent for warm restart
628
600
# Ask orchagent_restart_check to try freeze 5 times with interval of 2 seconds,
629
601
# it is possible that the orchagent is in transient state and no opportunity to freeze
655
627
# service will go down and we cannot recover from it.
656
628
set +e
657
629
630
+ if [[ " $REBOOT_TYPE " = " fast-reboot" ]]; then
631
+ # Clear all routes except of default routes for faster reconciliation time.
632
+ sonic-db-cli APPL_DB eval "
633
+ for _, k in ipairs(redis.call('keys', '*')) do
634
+ if string.match(k, 'ROUTE_TABLE:') and not string.match(k, 'ROUTE_TABLE:0.0.0.0/0') and not string.match(k, 'ROUTE_TABLE:::/0') then \
635
+ redis.call('del', k)
636
+ end
637
+ end
638
+ " 0 > /dev/null
639
+ fi
640
+
658
641
# disable trap-handlers which were set before
659
642
trap ' ' EXIT HUP INT QUIT TERM KILL ABRT ALRM
660
643
@@ -716,18 +699,19 @@ for service in ${SERVICES_TO_STOP}; do
716
699
if [[ " x$sonic_asic_type " == x" mellanox" ]]; then
717
700
check_issu_bank_file
718
701
fi
702
+ fi
719
703
720
- # Warm reboot: dump state to host disk
721
- if [[ " $REBOOT_TYPE " = " fastfast-reboot" ]]; then
722
- sonic-db-cli ASIC_DB FLUSHDB > /dev/null
723
- sonic-db-cli COUNTERS_DB FLUSHDB > /dev/null
724
- sonic-db-cli FLEX_COUNTER_DB FLUSHDB > /dev/null
725
- fi
726
-
727
- # TODO: backup_database preserves FDB_TABLE
728
- # need to cleanup as well for fastfast boot case
729
- backup_database
704
+ if [[ " $REBOOT_TYPE " = " fastfast-reboot" || " $REBOOT_TYPE " = " fast-reboot" ]]; then
705
+ # Advanced reboot: dump state to host disk
706
+ sonic-db-cli ASIC_DB FLUSHDB > /dev/null
707
+ sonic-db-cli COUNTERS_DB FLUSHDB > /dev/null
708
+ sonic-db-cli FLEX_COUNTER_DB FLUSHDB > /dev/null
730
709
fi
710
+
711
+ # TODO: backup_database preserves FDB_TABLE
712
+ # need to cleanup as well for fastfast boot case
713
+ backup_database
714
+
731
715
fi
732
716
done
733
717
0 commit comments