Skip to content

Commit 4a00fd6

Browse files
authored
xcvrd: gate config publish on syncd.restore_count = 1 (instead of system warm-reboot flag) to prevent post-warm-reboot port flaps (#666)
* Use syncd store count to check if it's warm-reboot * Modify condition. * Fixed comments * Modify table name * Change restore count to int to compare. * Compare with integer * Modify function name * Remove .swp file
1 parent f507630 commit 4a00fd6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

sonic-xcvrd/xcvrd/xcvrd.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,16 @@ def is_warm_reboot_enabled():
464464
is_warm_start = warmstart.isWarmStart()
465465
return is_warm_start
466466

467+
def is_syncd_warm_restore_complete():
468+
"""
469+
This function determins whether syncd's restore count is not 0, which indicates warm-reboot
470+
to avoid premature config push by xcvrd that caused port flaps.
471+
"""
472+
state_db = daemon_base.db_connect("STATE_DB")
473+
restore_count = state_db.hget("WARM_RESTART_TABLE|syncd", "restore_count") or "0"
474+
system_enabled = state_db.hget("WARM_RESTART_ENABLE_TABLE|system", "enable")
475+
return int(restore_count.strip()) > 0 or "true" in system_enabled
476+
467477
#
468478
# Helper classes ===============================================================
469479
#
@@ -1596,7 +1606,7 @@ def _post_port_sfp_info_and_dom_thr_to_db_once(self, port_mapping, xcvr_table_he
15961606
transceiver_dict = {}
15971607
retry_eeprom_set = set()
15981608

1599-
is_warm_start = is_warm_reboot_enabled()
1609+
is_warm_start = is_syncd_warm_restore_complete()
16001610
# Post all the current interface sfp/dom threshold info to STATE_DB
16011611
logical_port_list = port_mapping.logical_port_list
16021612
for logical_port_name in logical_port_list:
@@ -2324,7 +2334,7 @@ def init(self):
23242334
def deinit(self):
23252335
self.log_info("Start daemon deinit...")
23262336

2327-
is_warm_fast_reboot = is_warm_reboot_enabled() or is_fast_reboot_enabled()
2337+
is_warm_fast_reboot = is_syncd_warm_restore_complete() or is_fast_reboot_enabled()
23282338

23292339
# Delete all the information from DB and then exit
23302340
port_mapping_data = port_event_helper.get_port_mapping(self.namespaces)

0 commit comments

Comments
 (0)