Skip to content

Commit bb56fc2

Browse files
Update swss_ready check to check per namespace swss service (sonic-net#1974)
What I did fixes sonic-net#9411 on multi-asic platform, config reload CLI was not working without -f option. This was because swss_ready function was checking status of swss.service and multi-asic platform will not have swss.service, it will have per-namespace swss service. How I did it Fix swss_ready function to check all swss services status running on the platform.
1 parent 4f39f9f commit bb56fc2

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

config/main.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -767,18 +767,34 @@ def _delay_timers_elapsed():
767767
return False
768768
return True
769769

770-
def _swss_ready():
771-
out = clicommon.run_command("systemctl show swss.service --property ActiveState --value", return_cmd=True)
770+
def _per_namespace_swss_ready(service_name):
771+
out = clicommon.run_command("systemctl show {} --property ActiveState --value".format(service_name), return_cmd=True)
772772
if out.strip() != "active":
773773
return False
774-
out = clicommon.run_command("systemctl show swss.service --property ActiveEnterTimestampMonotonic --value", return_cmd=True)
774+
out = clicommon.run_command("systemctl show {} --property ActiveEnterTimestampMonotonic --value".format(service_name), return_cmd=True)
775775
swss_up_time = float(out.strip())/1000000
776776
now = time.monotonic()
777777
if (now - swss_up_time > 120):
778778
return True
779779
else:
780780
return False
781781

782+
def _swss_ready():
783+
list_of_swss = []
784+
num_asics = multi_asic.get_num_asics()
785+
if num_asics == 1:
786+
list_of_swss.append("swss.service")
787+
else:
788+
for asic in range(num_asics):
789+
service = "swss@{}.service".format(asic)
790+
list_of_swss.append(service)
791+
792+
for service_name in list_of_swss:
793+
if _per_namespace_swss_ready(service_name) == False:
794+
return False
795+
796+
return True
797+
782798
def _is_system_starting():
783799
out = clicommon.run_command("sudo systemctl is-system-running", return_cmd=True)
784800
return out.strip() == "starting"

0 commit comments

Comments
 (0)