From c035b565675d4bbf47e62e03b36ccac05d135da4 Mon Sep 17 00:00:00 2001 From: "Austin (Ngoc Thang) Pham" Date: Wed, 20 May 2026 21:46:28 +1000 Subject: [PATCH] fix(ptfadapter): tolerate supervisorctl restart spawn errors The start_ptf_nn_agent retry loop in the ptfadapter fixture calls 'supervisorctl restart ptf_nn_agent' without module_ignore_errors=True. When supervisord returns a non-zero exit code (for example, 'ERROR (spawn error)' on a port collision with the randomly-picked ptf_nn_port), Ansible raises and the surrounding 3-iteration retry loop never runs. The fixture aborts in setup and any test depending on ptfadapter errors out. Pass module_ignore_errors=True so the loop can pick a different random port. Also harden the supervisorctl status parsing against an empty stdout_lines list to avoid an IndexError. Signed-off-by: Austin (Ngoc Thang) Pham --- tests/common/plugins/ptfadapter/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/common/plugins/ptfadapter/__init__.py b/tests/common/plugins/ptfadapter/__init__.py index 7f68a927abb..73327188748 100644 --- a/tests/common/plugins/ptfadapter/__init__.py +++ b/tests/common/plugins/ptfadapter/__init__.py @@ -188,11 +188,15 @@ def start_ptf_nn_agent(device_num): ptfhost.command('supervisorctl update') # Force a restart of ptf_nn_agent to ensure that it is in good status. - ptfhost.command('supervisorctl restart ptf_nn_agent') + # Ignore command errors so that a transient "ERROR (spawn error)" (for + # example, a port collision on the randomly-picked ptf_nn_port) does + # not bypass the surrounding retry loop with a different port. + ptfhost.command('supervisorctl restart ptf_nn_agent', module_ignore_errors=True) # check whether ptf_nn_agent starts successfully - if "RUNNING" in ptfhost.command('supervisorctl status ptf_nn_agent', - module_ignore_errors=True)["stdout_lines"][0]: + status_lines = ptfhost.command('supervisorctl status ptf_nn_agent', + module_ignore_errors=True)["stdout_lines"] + if status_lines and "RUNNING" in status_lines[0]: return ptf_nn_port return None