Skip to content

Commit

Permalink
Remove syslog service validator in GCU (sonic-net#2991)
Browse files Browse the repository at this point in the history
### What I did
Remove rsyslog related service validator in GCU because it has been supported in latest image
#### How I did it
Remove related code
#### How to verify it
Unit test
  • Loading branch information
wen587 authored and JunhongMao committed Oct 4, 2023
1 parent 0a37b69 commit 27a8d50
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 31 deletions.
6 changes: 0 additions & 6 deletions generic_config_updater/gcu_services_validator.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
"PORT": {
"services_to_validate": [ "port_service" ]
},
"SYSLOG_SERVER":{
"services_to_validate": [ "rsyslog" ]
},
"DHCP_RELAY": {
"services_to_validate": [ "dhcp-relay" ]
},
Expand All @@ -60,9 +57,6 @@
"port_service": {
"validate_commands": [ ]
},
"rsyslog": {
"validate_commands": [ "generic_config_updater.services_validator.rsyslog_validator" ]
},
"dhcp-relay": {
"validate_commands": [ "generic_config_updater.services_validator.dhcp_validator" ]
},
Expand Down
8 changes: 0 additions & 8 deletions generic_config_updater/services_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ def _service_restart(svc_name):
return rc == 0


def rsyslog_validator(old_config, upd_config, keys):
rc = os.system("/usr/bin/rsyslog-config.sh")
if rc != 0:
return _service_restart("rsyslog")
else:
return True


def dhcp_validator(old_config, upd_config, keys):
return _service_restart("dhcp_relay")

Expand Down
18 changes: 1 addition & 17 deletions tests/generic_config_updater/service_validator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections import defaultdict
from unittest.mock import patch

from generic_config_updater.services_validator import vlan_validator, rsyslog_validator, caclmgrd_validator, vlanintf_validator
from generic_config_updater.services_validator import vlan_validator, caclmgrd_validator, vlanintf_validator
import generic_config_updater.gu_common


Expand Down Expand Up @@ -142,16 +142,6 @@ def mock_time_sleep_call(sleep_time):
},
]

test_rsyslog_fail = [
# Fail the calls, to get the entire fail path calls invoked
#
{ "cmd": "/usr/bin/rsyslog-config.sh", "rc": 1 }, # config update; fails
{ "cmd": "systemctl restart rsyslog", "rc": 1 }, # rsyslog restart; fails
{ "cmd": "systemctl reset-failed rsyslog", "rc": 1 }, # reset; failure here just logs
{ "cmd": "systemctl restart rsyslog", "rc": 1 }, # restart again; fails
{ "cmd": "systemctl restart rsyslog", "rc": 1 }, # restart again; fails
]

test_vlanintf_data = [
{ "old": {}, "upd": {}, "cmd": "" },
{
Expand Down Expand Up @@ -211,12 +201,6 @@ def test_change_apply_os_system(self, mock_os_sys):

# Test failure case
#
os_system_calls = test_rsyslog_fail
os_system_call_index = 0

rc = rsyslog_validator("", "", "")
assert not rc, "rsyslog_validator expected to fail"

os_system_calls = []
os_system_call_index = 0
for entry in test_vlanintf_data:
Expand Down

0 comments on commit 27a8d50

Please sign in to comment.