Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

Expand Down
2 changes: 1 addition & 1 deletion pfc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand Down
15 changes: 12 additions & 3 deletions tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 ...
Expand All @@ -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 ...
Expand All @@ -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 ...
Expand All @@ -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
Expand All @@ -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 ...
Expand All @@ -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
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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)

Expand All @@ -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):
Expand Down
Loading