diff --git a/config/main.py b/config/main.py index b6c500393..592b7284e 100644 --- a/config/main.py +++ b/config/main.py @@ -1008,6 +1008,12 @@ def _stop_services(): except subprocess.CalledProcessError as err: pass + # Get the list of dependencies for sonic.target to fetch timer units + for service in _get_sonic_services(): + if service.endswith('.timer'): + # Stop the timer unit + clicommon.run_command(['sudo', 'systemctl', 'stop', service], display_cmd=True) + click.echo("Stopping SONiC target ...") clicommon.run_command(['sudo', 'systemctl', 'stop', 'sonic.target', '--job-mode', 'replace-irreversibly']) diff --git a/pfc/main.py b/pfc/main.py index f894a5d7c..626c26931 100644 --- a/pfc/main.py +++ b/pfc/main.py @@ -84,7 +84,7 @@ def configPfcPrio(self, status, interface, priority): """Current lossless priorities on the interface""" entry = self.config_db.get_entry('PORT_QOS_MAP', interface) - enable_prio = entry.get('pfc_enable').split(',') + enable_prio = entry.get('pfc_enable', '').split(',') """Avoid '' in enable_prio""" enable_prio = [x.strip() for x in enable_prio if x.strip()] diff --git a/tests/config_test.py b/tests/config_test.py index 67c824d5a..9736a571b 100644 --- a/tests/config_test.py +++ b/tests/config_test.py @@ -53,6 +53,7 @@ load_minigraph_command_output="""\ Acquired lock on {0} Disabling container and routeCheck monitoring ... +Running command: sudo systemctl stop featured.timer Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -H -m --write-to-db Running command: config qos reload --no-dynamic-buffer --no-delay @@ -70,6 +71,7 @@ load_minigraph_command_bypass_lock_output = """\ Bypass lock on {} +Running command: sudo systemctl stop featured.timer Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -H -m --write-to-db Running command: config qos reload --no-dynamic-buffer --no-delay @@ -81,6 +83,7 @@ load_minigraph_platform_plugin_command_output="""\ Acquired lock on {0} +Running command: sudo systemctl stop featured.timer Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -H -m --write-to-db Running command: config qos reload --no-dynamic-buffer --no-delay @@ -165,6 +168,7 @@ RELOAD_CONFIG_DB_OUTPUT = """\ Acquired lock on {0} +Running command: sudo systemctl stop featured.timer Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -j /tmp/config.json --write-to-db Restarting SONiC target ... @@ -178,6 +182,7 @@ RELOAD_CONFIG_DB_BYPASS_LOCK_OUTPUT = """\ Bypass lock on {0} +Running command: sudo systemctl stop featured.timer Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -j /tmp/config.json --write-to-db Restarting SONiC target ... @@ -186,6 +191,7 @@ RELOAD_YANG_CFG_OUTPUT = """\ Acquired lock on {0} +Running command: sudo systemctl stop featured.timer Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -Y /tmp/config.json --write-to-db Restarting SONiC target ... @@ -195,6 +201,7 @@ RELOAD_MASIC_CONFIG_DB_OUTPUT = """\ Acquired lock on {0} +Running command: sudo systemctl stop featured.timer Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -j /tmp/config.json --write-to-db Running command: /usr/local/bin/sonic-cfggen -j /tmp/config0.json -n asic0 --write-to-db @@ -219,6 +226,7 @@ reload_config_masic_onefile_output = """\ Acquired lock on {0} +Running command: sudo systemctl stop featured.timer Stopping SONiC target ... Restarting SONiC target ... Reloading Monit configuration ... @@ -227,6 +235,7 @@ reload_config_masic_onefile_gen_sysinfo_output = """\ Acquired lock on {0} +Running command: sudo systemctl stop featured.timer Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -H -k Mellanox-SN3800-D112C8 --write-to-db Running command: /usr/local/bin/sonic-cfggen -H -k multi_asic -n asic0 --write-to-db @@ -1148,7 +1157,7 @@ def test_load_minigraph(self, mock_check_call, get_cmd_module, setup_single_broa # Verify "systemctl reset-failed" is called for services under sonic.target mock_run_command.assert_any_call(['systemctl', 'reset-failed', 'swss']) mock_run_command.assert_any_call(['systemctl', 'reset-failed', 'pmon']) - assert mock_run_command.call_count == 21 + assert mock_run_command.call_count == 23 @mock.patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', mock.MagicMock(return_value=("dummy_path", None))) @@ -1194,7 +1203,7 @@ def test_load_minigraph_bypass_lock(self, get_cmd_module, setup_single_broadcom_ load_minigraph_command_bypass_lock_output.format(config.SYSTEM_RELOAD_LOCK) mock_run_command.assert_any_call(['systemctl', 'reset-failed', 'swss']) mock_run_command.assert_any_call(['systemctl', 'reset-failed', 'pmon']) - assert mock_run_command.call_count == 15 + assert mock_run_command.call_count == 17 finally: flock.release_flock(fd) @@ -1213,7 +1222,7 @@ def test_load_minigraph_platform_plugin(self, get_cmd_module, setup_single_broad # Verify "systemctl reset-failed" is called for services under sonic.target mock_run_command.assert_any_call(['systemctl', 'reset-failed', 'swss']) mock_run_command.assert_any_call(['systemctl', 'reset-failed', 'pmon']) - assert mock_run_command.call_count == 15 + assert mock_run_command.call_count == 17 @mock.patch('sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs', mock.MagicMock(return_value=(load_minigraph_platform_false_path, None))) def test_load_minigraph_platform_plugin_fail(self, get_cmd_module, setup_single_broadcom_asic):