aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2020-02-12 22:36:28 +0100
committerBryan Quigley <bryan.quigley@canonical.com>2020-02-12 15:48:25 -0800
commitdad96c5b8bf174216be5bb10f4b26cf23f374ab2 (patch)
tree21811c159d7fb719af524bb655b969b3ed389161
parent2addff6c4f0bebfcaa515240c84ff7f37377fca6 (diff)
downloadsos-dad96c5b8bf174216be5bb10f4b26cf23f374ab2.tar.gz
[plugins] set default cmd timeout to add_journal
add_journal calls a sos command underneath that should apply same command timeout limits like e.g. add_cmd_output method. Further, define the command timeout value of 300 seconds just on one place. Resolves: #1938, #1946 Signed-off-by: Pavel Moravec <pmoravec@redhat.com> Signed-off-by: Bryan Quigley <bryan.quigley@canonical.com>
-rw-r--r--sos/plugins/__init__.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index cc284d06..7f1b5ea2 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -363,6 +363,7 @@ class Plugin(object):
profiles = ()
sysroot = '/'
plugin_timeout = 300
+ cmd_timeout = 300
_timeout_hit = False
# Default predicates
@@ -1084,7 +1085,7 @@ class Plugin(object):
changes=soscmd.changes)
def add_cmd_output(self, cmds, suggest_filename=None,
- root_symlink=None, timeout=300, stderr=True,
+ root_symlink=None, timeout=cmd_timeout, stderr=True,
chroot=True, runat=None, env=None, binary=False,
sizelimit=None, pred=None, subdir=None,
changes=False, foreground=False):
@@ -1190,8 +1191,8 @@ class Plugin(object):
self._log_debug("added string ...'%s' as '%s'" % (summary, filename))
def _collect_cmd_output(self, cmd, suggest_filename=None,
- root_symlink=False, timeout=300, stderr=True,
- chroot=True, runat=None, env=None,
+ root_symlink=False, timeout=cmd_timeout,
+ stderr=True, chroot=True, runat=None, env=None,
binary=False, sizelimit=None, subdir=None,
changes=False, foreground=False):
"""Execute a command and save the output to a file for inclusion in the
@@ -1284,8 +1285,8 @@ class Plugin(object):
return result
def collect_cmd_output(self, cmd, suggest_filename=None,
- root_symlink=False, timeout=300, stderr=True,
- chroot=True, runat=None, env=None,
+ root_symlink=False, timeout=cmd_timeout,
+ stderr=True, chroot=True, runat=None, env=None,
binary=False, sizelimit=None, pred=None,
subdir=None):
"""Execute a command and save the output to a file for inclusion in the
@@ -1306,8 +1307,9 @@ class Plugin(object):
env=env, binary=binary, sizelimit=sizelimit, subdir=subdir
)
- def exec_cmd(self, cmd, timeout=300, stderr=True, chroot=True, runat=None,
- env=None, binary=False, pred=None, foreground=False):
+ def exec_cmd(self, cmd, timeout=cmd_timeout, stderr=True, chroot=True,
+ runat=None, env=None, binary=False, pred=None,
+ foreground=False):
"""Execute a command right now and return the output and status, but
do not save the output within the archive.
@@ -1368,8 +1370,9 @@ class Plugin(object):
self._add_cmd_output(cmd="%s %s" % (query, service), **kwargs)
def add_journal(self, units=None, boot=None, since=None, until=None,
- lines=None, allfields=False, output=None, timeout=None,
- identifier=None, catalog=None, sizelimit=None, pred=None):
+ lines=None, allfields=False, output=None,
+ timeout=cmd_timeout, identifier=None, catalog=None,
+ sizelimit=None, pred=None):
"""Collect journald logs from one of more units.
:param units: A string, or list of strings specifying the