Skip to content

Commit d1203ef

Browse files
authored
Update xcvrd to use new STATE_DB FAST_REBOOT entry (#335)
Update xcvrd to check if fast-reboot is enabled according to the new value for FAST_REBOOT entry in STATE_DB. This PR should come along with the following PRs: sonic-net/sonic-utilities#2621 sonic-net/sonic-buildimage#13484 sonic-net/sonic-swss-common#742 sonic-net/sonic-sairedis#1196 This set of PRs solves the issue sonic-net/sonic-buildimage#13251 Description Update xcvrd to check the updated form of fast-reboot entry in state-db as it was changed. Motivation and Context Introducing fast-reboot finalizer on top of warmboot-finalizer, fast-reboot entry in STATE_DB is now changed from "1"/None to "enable"/"disable". How Has This Been Tested? Existing tests, and fast-reboot.
1 parent 9f3a124 commit d1203ef

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

sonic-xcvrd/tests/test_xcvrd.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,10 +1518,13 @@ def test_get_media_val_str(self):
15181518
@patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', MagicMock(return_value=('/tmp', None)))
15191519
@patch('swsscommon.swsscommon.WarmStart', MagicMock())
15201520
@patch('xcvrd.xcvrd.DaemonXcvrd.wait_for_port_config_done', MagicMock())
1521-
def test_DaemonXcvrd_init_deinit(self):
1521+
def test_DaemonXcvrd_init_deinit_fastboot_enabled(self):
15221522
xcvrd = DaemonXcvrd(SYSLOG_IDENTIFIER)
1523-
xcvrd.init()
1524-
xcvrd.deinit()
1523+
with patch("subprocess.check_output") as mock_run:
1524+
mock_run.return_value = "true"
1525+
1526+
xcvrd.init()
1527+
xcvrd.deinit()
15251528

15261529

15271530
def wait_until(total_wait_time, interval, call_back, *args, **kwargs):

sonic-xcvrd/xcvrd/xcvrd.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -921,17 +921,8 @@ def init_port_sfp_status_tbl(port_mapping, xcvr_table_helper, stop_event=threadi
921921
update_port_transceiver_status_table_sw(logical_port_name, xcvr_table_helper.get_status_tbl(asic_index), sfp_status_helper.SFP_STATUS_INSERTED)
922922

923923
def is_fast_reboot_enabled():
924-
fastboot_enabled = False
925-
state_db_host = daemon_base.db_connect("STATE_DB")
926-
fastboot_tbl = swsscommon.Table(state_db_host, 'FAST_REBOOT')
927-
keys = fastboot_tbl.getKeys()
928-
929-
if "system" in keys:
930-
output = subprocess.check_output(['sonic-db-cli', 'STATE_DB', 'get', "FAST_REBOOT|system"], universal_newlines=True)
931-
if "1" in output:
932-
fastboot_enabled = True
933-
934-
return fastboot_enabled
924+
fastboot_enabled = subprocess.check_output('sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable', shell=True, universal_newlines=True)
925+
return "true" in fastboot_enabled
935926

936927
#
937928
# Helper classes ===============================================================

0 commit comments

Comments
 (0)