From be26dd6b788d3731aef097627dd902e699095484 Mon Sep 17 00:00:00 2001 From: Eduardo Olivares Date: Fri, 19 Jan 2024 17:38:13 +0100 Subject: [PATCH] Use configured process timeout when closing a process Some processes get blocked waiting while they cannot read from either stdout or stderr. The command timeout was not applied when tobiko tried to close those processes. With this patch, those processes will be closed due to timeout and the tobiko retries mechanism would be able to retry the command. Change-Id: I1836de50cbbe029f7c474598ec57ea2e52822dd1 --- tobiko/shell/ping/_ping.py | 2 +- tobiko/shell/sh/_process.py | 2 ++ tobiko/tripleo/pacemaker.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tobiko/shell/ping/_ping.py b/tobiko/shell/ping/_ping.py index 2aa8e79a0..0bd94466e 100644 --- a/tobiko/shell/ping/_ping.py +++ b/tobiko/shell/ping/_ping.py @@ -328,7 +328,7 @@ def execute_ping(parameters, ssh_client=None, check=True): try: result = sh.execute(command=command, ssh_client=ssh_client, - timeout=parameters.deadline + 2., + timeout=parameters.deadline + 3., expect_exit_status=None, network_namespace=parameters.network_namespace) except sh.ShellError as ex: diff --git a/tobiko/shell/sh/_process.py b/tobiko/shell/sh/_process.py index bfd748144..d9a2c541a 100644 --- a/tobiko/shell/sh/_process.py +++ b/tobiko/shell/sh/_process.py @@ -197,6 +197,8 @@ class ShellProcessFixture(tobiko.SharedFixture): LOG.exception("Error closing STDERR stream: %r", self.stderr) def close(self, timeout: tobiko.Seconds = None): + if timeout is None: + timeout = self.parameters.timeout self.close_stdin() try: # Drain all incoming data from STDOUT and STDERR diff --git a/tobiko/tripleo/pacemaker.py b/tobiko/tripleo/pacemaker.py index 62f7c216a..0885dc9fd 100644 --- a/tobiko/tripleo/pacemaker.py +++ b/tobiko/tripleo/pacemaker.py @@ -413,6 +413,7 @@ def run_pcs_resource_operation(resource: str, output = execute_pcs(command_args, ssh_client=ssh_client, add_stderr=add_stderr, + timeout=operation_wait + 10., sudo=True) except sh.ShellCommandFailed as exc: if attempt.is_last: