Skip to content

Commit

Permalink
Update swss_ready check to check per namespace swss service (sonic-ne…
Browse files Browse the repository at this point in the history
…t#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.
  • Loading branch information
SuvarnaMeenakshi committed Dec 22, 2021
1 parent 4f39f9f commit bb56fc2
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,18 +767,34 @@ 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):
return True
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"
Expand Down

0 comments on commit bb56fc2

Please sign in to comment.