From bb56fc2c834a194df342bb3d52b086325cd3a9ac Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi <50386592+SuvarnaMeenakshi@users.noreply.github.com> Date: Tue, 21 Dec 2021 17:12:06 -0800 Subject: [PATCH] Update swss_ready check to check per namespace swss service (#1974) What I did fixes Azure/sonic-buildimage#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. --- config/main.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/config/main.py b/config/main.py index 370958856b..5046275f6e 100644 --- a/config/main.py +++ b/config/main.py @@ -767,11 +767,11 @@ def _delay_timers_elapsed(): return False return True -def _swss_ready(): - out = clicommon.run_command("systemctl show swss.service --property ActiveState --value", return_cmd=True) +def _per_namespace_swss_ready(service_name): + out = clicommon.run_command("systemctl show {} --property ActiveState --value".format(service_name), return_cmd=True) if out.strip() != "active": return False - out = clicommon.run_command("systemctl show swss.service --property ActiveEnterTimestampMonotonic --value", return_cmd=True) + out = clicommon.run_command("systemctl show {} --property ActiveEnterTimestampMonotonic --value".format(service_name), return_cmd=True) swss_up_time = float(out.strip())/1000000 now = time.monotonic() if (now - swss_up_time > 120): @@ -779,6 +779,22 @@ def _swss_ready(): else: return False +def _swss_ready(): + list_of_swss = [] + num_asics = multi_asic.get_num_asics() + if num_asics == 1: + list_of_swss.append("swss.service") + else: + for asic in range(num_asics): + service = "swss@{}.service".format(asic) + list_of_swss.append(service) + + for service_name in list_of_swss: + if _per_namespace_swss_ready(service_name) == False: + return False + + return True + def _is_system_starting(): out = clicommon.run_command("sudo systemctl is-system-running", return_cmd=True) return out.strip() == "starting"