Skip to content

Commit

Permalink
Added support for returning failure reason if config_system_checks_pa…
Browse files Browse the repository at this point in the history
…ssed fails (#5975)

What is the motivation for this PR?
One of the tasks performed by config_system_checks_passed definition is to check if the dut is running.
This is done by executing the command "systemctl is-system-running". It returns "False" If the dut is not running
but it does not check why the dut is not running.
We need to add support for checking the failure reason

How did you do it?
Execute the command "systemctl is-system-running". Pass if dut is running.
Execute the command "systemctl list-units --state=failed" if dut is not running. This will provide the failure reason.
Example of failure reason: In this case tacacs-config.timer loaded failed
base.py:82 /data/tests/common/devices/multi_asic.py::_run_on_asics#100: [ixre-cpm-chassis10] AnsibleModule::shell Result =>
{"stderr_lines": [], "cmd": "systemctl list-units --state=failed", "end": "2022-07-09 10:12:18.720054", "_ansible_no_log": false,
"stdout": "UNIT LOAD ACTIVE SUB DESCRIPTION\n\u25cf tacacs-config.timer loaded failed failed Delays tacacs apply until SONiC has started\n\n
LOAD = Reflects whether the unit definition was properly loaded.\nACTIVE = The high-level unit activation state, i.e. generalization of SUB.\n
SUB = The low-level unit activation state, values depend on unit type.\n1 loaded units listed."
How did you verify/test it?
Tested the code on a dut when it was in the "running" state
Tested the code on a dut when it was in the "degraded" state
  • Loading branch information
mannytaheri authored Jul 27, 2022
1 parent d4edaa3 commit c7d1948
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/common/config_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@

def config_system_checks_passed(duthost):
logging.info("Checking if system is running")
out=duthost.shell("systemctl is-system-running")
if "running" not in out['stdout']:
out= duthost.shell("systemctl is-system-running", module_ignore_errors=True)
if "running" not in out['stdout_lines']:
logging.info("Checking failure reason")
fail_reason = duthost.shell("systemctl list-units --state=failed", module_ignore_errors=True)
logging.info(fail_reason['stdout_lines'])
return False

logging.info("Checking if Orchagent up for at least 2 min")
Expand Down

0 comments on commit c7d1948

Please sign in to comment.