aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2019-07-26 11:44:53 +0200
committerBryn M. Reeves <bmr@redhat.com>2019-07-29 18:47:12 +0100
commit8ad1f5977adfa11880aae4144d554ad1cc99ad63 (patch)
treee787107ca6497802e1ee8a70e002c5caadc85e90
parent34219ce0e15de5423baaaa1054a98cf1b58f0eae (diff)
downloadsos-8ad1f5977adfa11880aae4144d554ad1cc99ad63.tar.gz
[plugins] Stop plugin execution after timeout hit
When a plugin timeouts, it must stop collecting further data. Otherwise a race issues with archive.finalize() can happen. So any data collection must be skipped if _timeout_hit is True. Resolves: #1736 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/plugins/__init__.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index e5bb39ee..aa268d84 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -652,6 +652,9 @@ class Plugin(object):
everything below it is recursively copied. A list of copied files are
saved for use later in preparing a report.
'''
+ if self._timeout_hit:
+ return
+
if self._is_forbidden_path(srcpath):
self._log_debug("skipping forbidden path '%s'" % srcpath)
return ''
@@ -852,6 +855,9 @@ class Plugin(object):
def get_command_output(self, prog, timeout=300, stderr=True,
chroot=True, runat=None, env=None,
binary=False, sizelimit=None):
+ if self._timeout_hit:
+ return
+
if chroot or self.commons['cmdlineopts'].chroot == 'always':
root = self.sysroot
else:
@@ -1012,6 +1018,9 @@ class Plugin(object):
"""Execute a command and save the output to a file for inclusion in the
report.
"""
+ if self._timeout_hit:
+ return
+
start = time()
result = self.get_command_output(cmd, timeout=timeout, stderr=stderr,
@@ -1201,6 +1210,8 @@ class Plugin(object):
def _collect_strings(self):
for string, file_name in self.copy_strings:
+ if self._timeout_hit:
+ return
content = ''
if string:
content = string.splitlines()[0]