Apply retries when ping execution fails due to ssh issues

When tobiko executes remote ping commands, they could fail due to:
- command error
- error connecting to the remove server to run ping
In the second case, the exception raised is a RetryLimitError. If that
exception is not captured, retries cannot be applied.

Change-Id: I00a76bb16de14440b25aeda00ee25b8d196992dd
This commit is contained in:
Eduardo Olivares 2024-03-21 10:53:51 +01:00
parent ff9c70dbc4
commit f650d7adcb
2 changed files with 7 additions and 6 deletions

View File

@ -331,10 +331,10 @@ def execute_ping(parameters, ssh_client=None, check=True):
timeout=parameters.deadline + 3.,
expect_exit_status=None,
network_namespace=parameters.network_namespace)
except sh.ShellError as ex:
except (sh.ShellError, tobiko.RetryLimitError) as ex:
LOG.exception("Error executing ping command")
stdout = ex.stdout
stderr = ex.stderr
stdout = ex.stdout if hasattr(ex, "stdout") else None
stderr = ex.stderr if hasattr(ex, "stderr") else None
else:
stdout = result.stdout
stderr = result.stderr

View File

@ -352,11 +352,12 @@ class ShellProcessFixture(tobiko.SharedFixture):
attempt.check_limits()
except tobiko.RetryTimeLimitError:
LOG.exception("retry timeout expired")
# Eventually raises either ShellCommandTimeout exception or
# RetryTimeLimitError
self.get_exit_status(timeout=timeout)
raise
else:
return
# Eventually raises ShellCommandTimeout exception
self.get_exit_status(timeout=timeout)
raise StopIteration
def _is_communicating(self, streams, send, receive):
if send and self.stdin in streams: