Skip to content

Commit 1e0771c

Browse files
authored
Merge pull request #158 from mssonicbld/sonicbld/202205-merge
[code sync] Merge code from sonic-net/sonic-buildimage:202205 to 202205
2 parents ba97ce6 + 0ad4ed4 commit 1e0771c

File tree

4 files changed

+127
-23
lines changed

4 files changed

+127
-23
lines changed

platform/components/docker-gbsyncd-credo.mk

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
DOCKER_GBSYNCD_PLATFORM_CODE = credo
22

3-
LIBSAI_CREDO = libsaicredo_0.8.2_amd64.deb
4-
$(LIBSAI_CREDO)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo_0.8.2_amd64.deb?sv=2021-04-10&st=2023-01-31T04%3A24%3A23Z&se=2100-01-31T04%3A24%3A00Z&sr=b&sp=r&sig=RZPbmaIetvDRtwifrVT4s%2FaQxB%2FBTOyCqXtMtoNRjmY%3D"
5-
LIBSAI_CREDO_OWL = libsaicredo-owl_0.8.2_amd64.deb
6-
$(LIBSAI_CREDO_OWL)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo-owl_0.8.2_amd64.deb?sv=2021-04-10&st=2023-01-31T04%3A25%3A43Z&se=2100-01-31T04%3A25%3A00Z&sr=b&sp=r&sig=%2BdSFujwy0gY%2FiH50Ffi%2FsqZOAHBOFPUcBdR06fHEZkI%3D"
3+
LIBSAI_CREDO = libsaicredo_0.9.3_amd64.deb
4+
$(LIBSAI_CREDO)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo_0.9.3_amd64.deb?sv=2021-04-10&st=2023-10-12T02%3A21%3A05Z&se=2031-10-13T02%3A21%3A00Z&sr=b&sp=r&sig=UXC%2FYKm%2BvHRjGmM3xjnFMQzY%2BMpxhKtMxNHQPdwvtN8%3D"
5+
LIBSAI_CREDO_OWL = libsaicredo-owl_0.9.3_amd64.deb
6+
$(LIBSAI_CREDO_OWL)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo-owl_0.9.3_amd64.deb?sv=2021-04-10&st=2023-10-12T02%3A21%3A51Z&se=2031-10-13T02%3A21%3A00Z&sr=b&sp=r&sig=olu3%2Bq5eJYRtXCygJWgKUx%2FdlrlB%2FWE0i9ruftYdB7g%3D"
77

88
ifneq ($($(LIBSAI_CREDO)_URL),)
99
include $(PLATFORM_PATH)/../template/docker-gbsyncd-base.mk

src/sonic-host-services/scripts/hostcfgd

+14-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,20 @@ class FeatureHandler(object):
364364
Returns:
365365
None.
366366
"""
367-
restart_field_str = "always" if "enabled" in feature_config.auto_restart else "no"
367+
# As per the current code(due to various dependencies) SWSS service stop/start also stops/starts the dependent services(syncd, teamd, bgpd etc)
368+
# There is an issue seen of syncd service getting stopped twice upon a critical process crash in syncd service due to above reason.
369+
# Also early start of syncd service has traffic impact on VOQ chassis.
370+
# to fix the above issue, we are disabling the auto restart of syncd service as it will be started by swss service.
371+
# This change can be extended to other dependent services as well in future and also on pizza box platforms.
372+
373+
device_type = self._device_config.get('DEVICE_METADATA', {}).get('localhost', {}).get('type')
374+
is_dependent_service = feature_config.name in ['syncd', 'gbsyncd']
375+
if device_type == 'SpineRouter' and is_dependent_service:
376+
syslog.syslog(syslog.LOG_INFO, "Skipped setting Restart field in systemd for {}".format(feature_config.name))
377+
restart_field_str = "no"
378+
else:
379+
restart_field_str = "always" if "enabled" in feature_config.auto_restart else "no"
380+
368381
feature_systemd_config = "[Service]\nRestart={}\n".format(restart_field_str)
369382
feature_names, feature_suffixes = self.get_multiasic_feature_instances(feature_config)
370383

src/sonic-host-services/tests/hostcfgd/hostcfgd_test.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def checks_config_table(self, feature_table, expected_table):
4545

4646
return True if not ddiff else False
4747

48-
def checks_systemd_config_file(self, feature_table, feature_systemd_name_map=None):
48+
def checks_systemd_config_file(self, device_type, feature_table, feature_systemd_name_map=None):
4949
"""Checks whether the systemd configuration file of each feature was created or not
5050
and whether the `Restart=` field in the file is set correctly or not.
5151
@@ -62,6 +62,7 @@ def checks_systemd_config_file(self, feature_table, feature_systemd_name_map=Non
6262
'auto_restart.conf')
6363

6464
for feature_name in feature_table:
65+
is_dependent_feature = True if feature_name in ['syncd', 'gbsyncd'] else False
6566
auto_restart_status = feature_table[feature_name].get('auto_restart', 'disabled')
6667
if "enabled" in auto_restart_status:
6768
auto_restart_status = "enabled"
@@ -77,7 +78,10 @@ def checks_systemd_config_file(self, feature_table, feature_systemd_name_map=Non
7778

7879
with open(feature_systemd_config_file_path) as systemd_config_file:
7980
status = systemd_config_file.read().strip()
80-
assert status == '[Service]\nRestart={}'.format(truth_table[auto_restart_status])
81+
if device_type == 'SpineRouter' and is_dependent_feature:
82+
assert status == '[Service]\nRestart=no'
83+
else:
84+
assert status == '[Service]\nRestart={}'.format(truth_table[auto_restart_status])
8185

8286
def get_state_db_set_calls(self, feature_table):
8387
"""Returns a Mock call objects which recorded the `set` calls to `FEATURE` table in `STATE_DB`.
@@ -134,6 +138,7 @@ def test_sync_state_field(self, test_scenario_name, config_data, fs):
134138
device_config = {}
135139
device_config['DEVICE_METADATA'] = MockConfigDb.CONFIG_DB['DEVICE_METADATA']
136140
device_config.update(config_data['device_runtime_metadata'])
141+
device_type = MockConfigDb.CONFIG_DB['DEVICE_METADATA']['localhost']['type']
137142

138143
feature_handler = hostcfgd.FeatureHandler(MockConfigDb(), feature_state_table_mock, device_config)
139144
feature_table = MockConfigDb.CONFIG_DB['FEATURE']
@@ -158,13 +163,13 @@ def test_sync_state_field(self, test_scenario_name, config_data, fs):
158163

159164
feature_table_state_db_calls = self.get_state_db_set_calls(feature_table)
160165

161-
self.checks_systemd_config_file(config_data['config_db']['FEATURE'], feature_systemd_name_map)
166+
self.checks_systemd_config_file(device_type, config_data['config_db']['FEATURE'], feature_systemd_name_map)
162167
mocked_subprocess.check_call.assert_has_calls(config_data['enable_feature_subprocess_calls'],
163168
any_order=True)
164169
mocked_subprocess.check_call.assert_has_calls(config_data['daemon_reload_subprocess_call'],
165170
any_order=True)
166171
feature_state_table_mock.set.assert_has_calls(feature_table_state_db_calls)
167-
self.checks_systemd_config_file(config_data['config_db']['FEATURE'], feature_systemd_name_map)
172+
self.checks_systemd_config_file(device_type, config_data['config_db']['FEATURE'], feature_systemd_name_map)
168173

169174
@parameterized.expand(HOSTCFGD_TEST_VECTOR)
170175
@patchfs
@@ -196,6 +201,7 @@ def test_handler(self, test_scenario_name, config_data, fs):
196201
device_config = {}
197202
device_config['DEVICE_METADATA'] = MockConfigDb.CONFIG_DB['DEVICE_METADATA']
198203
device_config.update(config_data['device_runtime_metadata'])
204+
device_type = MockConfigDb.CONFIG_DB['DEVICE_METADATA']['localhost']['type']
199205
feature_handler = hostcfgd.FeatureHandler(MockConfigDb(), feature_state_table_mock, device_config)
200206

201207
feature_table = MockConfigDb.CONFIG_DB['FEATURE']
@@ -207,7 +213,7 @@ def test_handler(self, test_scenario_name, config_data, fs):
207213
feature_names, _ = feature_handler.get_multiasic_feature_instances(feature)
208214
feature_systemd_name_map[feature_name] = feature_names
209215

210-
self.checks_systemd_config_file(config_data['config_db']['FEATURE'], feature_systemd_name_map)
216+
self.checks_systemd_config_file(device_type, config_data['config_db']['FEATURE'], feature_systemd_name_map)
211217
mocked_subprocess.check_call.assert_has_calls(config_data['enable_feature_subprocess_calls'],
212218
any_order=True)
213219
mocked_subprocess.check_call.assert_has_calls(config_data['daemon_reload_subprocess_call'],

src/sonic-host-services/tests/hostcfgd/test_vectors.py

+98-13
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,14 @@
580580
"auto_restart": "enabled",
581581
"high_mem_alert": "disabled"
582582
},
583-
584-
583+
"syncd": {
584+
"state": "enabled",
585+
"has_timer": "False",
586+
"has_global_scope": "True",
587+
"has_per_asic_scope": "True",
588+
"auto_restart": "enabled",
589+
"high_mem_alert": "disabled"
590+
},
585591
},
586592
},
587593
"expected_config_db": {
@@ -610,12 +616,23 @@
610616
"high_mem_alert": "disabled",
611617
"state": "enabled"
612618
},
619+
"syncd": {
620+
"auto_restart": "enabled",
621+
"has_global_scope": "True",
622+
"has_per_asic_scope": "True",
623+
"has_timer": "False",
624+
"high_mem_alert": "disabled",
625+
"state": "enabled"
626+
},
613627
},
614628
},
615629
"enable_feature_subprocess_calls": [
616630
call("sudo systemctl stop bgp.service", shell=True),
617631
call("sudo systemctl disable bgp.service", shell=True),
618632
call("sudo systemctl mask bgp.service", shell=True),
633+
call("sudo systemctl start syncd.service", shell=True),
634+
call("sudo systemctl enable syncd.service", shell=True),
635+
call("sudo systemctl unmask syncd.service", shell=True),
619636
],
620637
"daemon_reload_subprocess_call": [
621638
call("sudo systemctl daemon-reload", shell=True),
@@ -675,8 +692,14 @@
675692
"auto_restart": "enabled",
676693
"high_mem_alert": "disabled"
677694
},
678-
679-
695+
"syncd": {
696+
"state": "enabled",
697+
"has_timer": "False",
698+
"has_global_scope": "True",
699+
"has_per_asic_scope": "True",
700+
"auto_restart": "enabled",
701+
"high_mem_alert": "disabled"
702+
},
680703
},
681704
},
682705
"expected_config_db": {
@@ -705,12 +728,23 @@
705728
"high_mem_alert": "disabled",
706729
"state": "enabled"
707730
},
731+
"syncd": {
732+
"auto_restart": "enabled",
733+
"has_global_scope": "True",
734+
"has_per_asic_scope": "True",
735+
"has_timer": "False",
736+
"high_mem_alert": "disabled",
737+
"state": "enabled"
738+
},
708739
},
709740
},
710741
"enable_feature_subprocess_calls": [
711742
call("sudo systemctl stop bgp.service", shell=True),
712743
call("sudo systemctl disable bgp.service", shell=True),
713744
call("sudo systemctl mask bgp.service", shell=True),
745+
call("sudo systemctl start syncd.service", shell=True),
746+
call("sudo systemctl enable syncd.service", shell=True),
747+
call("sudo systemctl unmask syncd.service", shell=True),
714748
],
715749
"daemon_reload_subprocess_call": [
716750
call("sudo systemctl daemon-reload", shell=True),
@@ -770,8 +804,14 @@
770804
"auto_restart": "enabled",
771805
"high_mem_alert": "disabled"
772806
},
773-
774-
807+
"syncd": {
808+
"state": "enabled",
809+
"has_timer": "False",
810+
"has_global_scope": "True",
811+
"has_per_asic_scope": "True",
812+
"auto_restart": "enabled",
813+
"high_mem_alert": "disabled"
814+
},
775815
},
776816
},
777817
"expected_config_db": {
@@ -800,6 +840,14 @@
800840
"high_mem_alert": "disabled",
801841
"state": "enabled"
802842
},
843+
"syncd": {
844+
"auto_restart": "enabled",
845+
"has_global_scope": "True",
846+
"has_per_asic_scope": "True",
847+
"has_timer": "False",
848+
"high_mem_alert": "disabled",
849+
"state": "enabled"
850+
},
803851
},
804852
},
805853
"enable_feature_subprocess_calls": [
@@ -809,7 +857,9 @@
809857
call("sudo systemctl start teamd.service", shell=True),
810858
call("sudo systemctl enable teamd.service", shell=True),
811859
call("sudo systemctl unmask teamd.service", shell=True),
812-
860+
call("sudo systemctl start syncd.service", shell=True),
861+
call("sudo systemctl enable syncd.service", shell=True),
862+
call("sudo systemctl unmask syncd.service", shell=True),
813863
],
814864
"daemon_reload_subprocess_call": [
815865
call("sudo systemctl daemon-reload", shell=True),
@@ -869,8 +919,14 @@
869919
"auto_restart": "enabled",
870920
"high_mem_alert": "disabled"
871921
},
872-
873-
922+
"syncd": {
923+
"state": "enabled",
924+
"has_timer": "False",
925+
"has_global_scope": "True",
926+
"has_per_asic_scope": "True",
927+
"auto_restart": "enabled",
928+
"high_mem_alert": "disabled"
929+
},
874930
},
875931
},
876932
"expected_config_db": {
@@ -899,6 +955,14 @@
899955
"high_mem_alert": "disabled",
900956
"state": "enabled"
901957
},
958+
"syncd": {
959+
"auto_restart": "enabled",
960+
"has_global_scope": "True",
961+
"has_per_asic_scope": "True",
962+
"has_timer": "False",
963+
"high_mem_alert": "disabled",
964+
"state": "enabled"
965+
},
902966
},
903967
},
904968
"enable_feature_subprocess_calls": [
@@ -908,7 +972,9 @@
908972
call("sudo systemctl start teamd.service", shell=True),
909973
call("sudo systemctl enable teamd.service", shell=True),
910974
call("sudo systemctl unmask teamd.service", shell=True),
911-
975+
call("sudo systemctl start syncd.service", shell=True),
976+
call("sudo systemctl enable syncd.service", shell=True),
977+
call("sudo systemctl unmask syncd.service", shell=True),
912978
],
913979
"daemon_reload_subprocess_call": [
914980
call("sudo systemctl daemon-reload", shell=True),
@@ -969,8 +1035,14 @@
9691035
"auto_restart": "enabled",
9701036
"high_mem_alert": "disabled"
9711037
},
972-
973-
1038+
"syncd": {
1039+
"state": "enabled",
1040+
"has_timer": "False",
1041+
"has_global_scope": "False",
1042+
"has_per_asic_scope": "True",
1043+
"auto_restart": "enabled",
1044+
"high_mem_alert": "disabled"
1045+
},
9741046
},
9751047
},
9761048
"expected_config_db": {
@@ -999,6 +1071,14 @@
9991071
"high_mem_alert": "disabled",
10001072
"state": "enabled"
10011073
},
1074+
"syncd": {
1075+
"auto_restart": "enabled",
1076+
"has_global_scope": "False",
1077+
"has_per_asic_scope": "True",
1078+
"has_timer": "False",
1079+
"high_mem_alert": "disabled",
1080+
"state": "enabled"
1081+
},
10021082
},
10031083
},
10041084
"enable_feature_subprocess_calls": [
@@ -1020,7 +1100,12 @@
10201100
call("sudo systemctl stop [email protected]", shell=True),
10211101
call("sudo systemctl disable [email protected]", shell=True),
10221102
call("sudo systemctl mask [email protected]", shell=True),
1023-
1103+
call("sudo systemctl start [email protected]", shell=True),
1104+
call("sudo systemctl enable [email protected]", shell=True),
1105+
call("sudo systemctl unmask [email protected]", shell=True),
1106+
call("sudo systemctl start [email protected]", shell=True),
1107+
call("sudo systemctl enable [email protected]", shell=True),
1108+
call("sudo systemctl unmask [email protected]", shell=True),
10241109
],
10251110
"daemon_reload_subprocess_call": [
10261111
call("sudo systemctl daemon-reload", shell=True),

0 commit comments

Comments
 (0)