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/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.

(cherry picked from commit bb56fc2)
  • Loading branch information
SuvarnaMeenakshi committed Feb 8, 2023
1 parent d08f59b commit 9372f3f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,33 @@ def _restart_services():
click.echo("Reloading Monit configuration ...")
clicommon.run_command("sudo monit reload")

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 {} --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 interface_is_in_vlan(vlan_member_table, interface_name):
""" Check if an interface is in a vlan """
Expand Down

0 comments on commit 9372f3f

Please sign in to comment.