Skip to content

Commit

Permalink
[config reload]: fix the condition for checking if system is starting (
Browse files Browse the repository at this point in the history
…#1766)

When systemd services finished, the systemd status could running
or degraded. Therefore, compare system status with starting directly.

Here is what is happening on kvm switch. Some services cannot be started.
Then, the system state is in degraded state.

```
admin@ARISTA01T1:~$ systemctl is-system-running
starting
admin@ARISTA01T1:~$ systemctl is-system-running
degraded
```

Signed-off-by: Guohan Lu <lguohan@gmail.com>
  • Loading branch information
lguohan authored Aug 17, 2021
1 parent 2c7cfaa commit dbcc6fd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from . import vxlan
from . import plugins
from .config_mgmt import ConfigMgmtDPB
from . import mclag
from . import mclag

# mock masic APIs for unit test
try:
Expand Down Expand Up @@ -727,9 +727,9 @@ def _swss_ready():
else:
return False

def _system_running():
def _is_system_starting():
out = clicommon.run_command("sudo systemctl is-system-running", return_cmd=True)
return out.strip() == "running"
return out.strip() == "starting"

def interface_is_in_vlan(vlan_member_table, interface_name):
""" Check if an interface is in a vlan """
Expand Down Expand Up @@ -1233,7 +1233,7 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, disable_arp_cach
<filename> : Names of configuration file(s) to load, separated by comma with no spaces in between
"""
if not force and not no_service_restart:
if not _system_running():
if _is_system_starting():
click.echo("System is not up. Retry later or use -f to avoid system checks")
return

Expand Down Expand Up @@ -1491,10 +1491,10 @@ def load_port_config(config_db, port_config_path):
# Validate if the input is an array
if not isinstance(port_config_input, list):
raise Exception("Bad format: port_config is not an array")

if len(port_config_input) == 0 or 'PORT' not in port_config_input[0]:
raise Exception("Bad format: PORT table not exists")

port_config = port_config_input[0]['PORT']

# Ensure all ports are exist
Expand Down

0 comments on commit dbcc6fd

Please sign in to comment.