Skip to content

Commit 98b0286

Browse files
authored
Ignore error teardown (#142)
1 parent 1d1d3f0 commit 98b0286

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

testgres/node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ def _try_shutdown(self, max_attempts, with_force=False):
359359
# The node has already stopped
360360
pass
361361

362-
# Check that node stopped
363-
p_status_output = self.os_ops.exec_command(f'ps -p {node_pid}', shell=True, expect_error=True).decode('utf-8')
362+
# Check that node stopped - print only column pid without headers
363+
p_status_output = self.os_ops.exec_command(f'ps -o pid= -p {node_pid}', shell=True, ignore_errors=True).decode('utf-8')
364364
if p_status_output and str(node_pid) in p_status_output:
365365
eprint(f'Failed to stop node {self.name}.')
366366
else:

testgres/operations/local_ops.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ def _run_command(self, cmd, shell, input, stdin, stdout, stderr, get_process, ti
107107
raise ExecUtilException("Command timed out after {} seconds.".format(timeout))
108108

109109
def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False, encoding=None, shell=False,
110-
text=False, input=None, stdin=None, stdout=None, stderr=None, get_process=False, timeout=None):
110+
text=False, input=None, stdin=None, stdout=None, stderr=None, get_process=False, timeout=None,
111+
ignore_errors=False):
111112
"""
112113
Execute a command in a subprocess and handle the output based on the provided parameters.
113114
"""
114115
process, output, error = self._run_command(cmd, shell, input, stdin, stdout, stderr, get_process, timeout, encoding)
115116
if get_process:
116117
return process
117-
if (process.returncode != 0 or has_errors(output=output, error=error)) and not expect_error:
118+
if not ignore_errors and ((process.returncode != 0 or has_errors(output=output, error=error)) and not expect_error):
118119
self._raise_exec_exception('Utility exited with non-zero code. Error `{}`', cmd, process.returncode, error or output)
119120

120121
if verbose:

testgres/operations/remote_ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __enter__(self):
6060

6161
def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
6262
encoding=None, shell=True, text=False, input=None, stdin=None, stdout=None,
63-
stderr=None, get_process=None, timeout=None):
63+
stderr=None, get_process=None, timeout=None, ignore_errors=False):
6464
"""
6565
Execute a command in the SSH session.
6666
Args:
@@ -98,7 +98,7 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
9898
marker in error for marker in ['error', 'Permission denied', 'fatal', 'No such file or directory']
9999
)
100100

101-
if error_found:
101+
if not ignore_errors and error_found:
102102
if isinstance(error, bytes):
103103
message = b"Utility exited with non-zero code. Error: " + error
104104
else:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy