Skip to content

Commit 2d624d8

Browse files
dgsudharsanarlakshm
authored andcommitted
[config reload] Fixing config reload when timer based delayed services are disabled (#1967)
#### What I did When timer based delayed services like mgmt-framework, telemetry and snmp are disabled and config reload is execute it fails Failed to reset failed state of unit mgmt-framework.service: Unit mgmt-framework.service not loaded. The reason is these services don't get masked like regular services and these are derived from timers. So when reset-failed is tried on these services it leads to exception. #### How I did it When the feature related to these services are disabled their timers would be masked and wouldn't be "enabled". So when deriving the services from timers the services which are not enabled will be skipped. #### How to verify it Disable services like mgmt-framework, snmp and telemetry and execute config reload. The config reload should execute without failure
1 parent ab3ed46 commit 2d624d8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

config/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,15 @@ def _get_sonic_services():
699699

700700

701701
def _get_delayed_sonic_services():
702-
out = clicommon.run_command("systemctl list-dependencies --plain sonic-delayed.target | sed '1d'", return_cmd=True)
703-
return (unit.strip().rstrip('.timer') for unit in out.splitlines())
702+
rc1 = clicommon.run_command("systemctl list-dependencies --plain sonic-delayed.target | sed '1d'", return_cmd=True)
703+
rc2 = clicommon.run_command("systemctl is-enabled {}".format(rc1.replace("\n", " ")), return_cmd=True)
704+
timer = [line.strip() for line in rc1.splitlines()]
705+
state = [line.strip() for line in rc2.splitlines()]
706+
services = []
707+
for unit in timer:
708+
if state[timer.index(unit)] == "enabled":
709+
services.append(unit.rstrip(".timer"))
710+
return services
704711

705712

706713
def _reset_failed_services():

tests/config_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def mock_run_command_side_effect(*args, **kwargs):
3939
return 'snmp.timer'
4040
elif command == "systemctl list-dependencies --plain sonic.target | sed '1d'":
4141
return 'swss'
42+
elif command == "systemctl is-enabled snmp.timer":
43+
return 'enabled'
4244
else:
4345
return ''
4446

@@ -66,7 +68,7 @@ def test_load_minigraph(self, get_cmd_module, setup_single_broadcom_asic):
6668
mock_run_command.assert_any_call('systemctl reset-failed swss')
6769
# Verify "systemctl reset-failed" is called for services under sonic-delayed.target
6870
mock_run_command.assert_any_call('systemctl reset-failed snmp')
69-
assert mock_run_command.call_count == 10
71+
assert mock_run_command.call_count == 11
7072

7173
@classmethod
7274
def teardown_class(cls):

0 commit comments

Comments
 (0)