|
|
30f6f4 |
From 8ad1f5977adfa11880aae4144d554ad1cc99ad63 Mon Sep 17 00:00:00 2001
|
|
|
30f6f4 |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
30f6f4 |
Date: Fri, 26 Jul 2019 11:44:53 +0200
|
|
|
30f6f4 |
Subject: [PATCH] [plugins] Stop plugin execution after timeout hit
|
|
|
30f6f4 |
|
|
|
30f6f4 |
When a plugin timeouts, it must stop collecting further data. Otherwise
|
|
|
30f6f4 |
a race issues with archive.finalize() can happen.
|
|
|
30f6f4 |
|
|
|
30f6f4 |
So any data collection must be skipped if _timeout_hit is True.
|
|
|
30f6f4 |
|
|
|
30f6f4 |
Resolves: #1736
|
|
|
30f6f4 |
|
|
|
30f6f4 |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
30f6f4 |
---
|
|
|
30f6f4 |
sos/plugins/__init__.py | 11 +++++++++++
|
|
|
30f6f4 |
1 file changed, 11 insertions(+)
|
|
|
30f6f4 |
|
|
|
30f6f4 |
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
|
|
|
30f6f4 |
index e5bb39ee..aa268d84 100644
|
|
|
30f6f4 |
--- a/sos/plugins/__init__.py
|
|
|
30f6f4 |
+++ b/sos/plugins/__init__.py
|
|
|
30f6f4 |
@@ -652,6 +652,9 @@ class Plugin(object):
|
|
|
30f6f4 |
everything below it is recursively copied. A list of copied files are
|
|
|
30f6f4 |
saved for use later in preparing a report.
|
|
|
30f6f4 |
'''
|
|
|
30f6f4 |
+ if self._timeout_hit:
|
|
|
30f6f4 |
+ return
|
|
|
30f6f4 |
+
|
|
|
30f6f4 |
if self._is_forbidden_path(srcpath):
|
|
|
30f6f4 |
self._log_debug("skipping forbidden path '%s'" % srcpath)
|
|
|
30f6f4 |
return ''
|
|
|
30f6f4 |
@@ -852,6 +855,9 @@ class Plugin(object):
|
|
|
30f6f4 |
def get_command_output(self, prog, timeout=300, stderr=True,
|
|
|
30f6f4 |
chroot=True, runat=None, env=None,
|
|
|
30f6f4 |
binary=False, sizelimit=None):
|
|
|
30f6f4 |
+ if self._timeout_hit:
|
|
|
30f6f4 |
+ return
|
|
|
30f6f4 |
+
|
|
|
30f6f4 |
if chroot or self.commons['cmdlineopts'].chroot == 'always':
|
|
|
30f6f4 |
root = self.sysroot
|
|
|
30f6f4 |
else:
|
|
|
30f6f4 |
@@ -1012,6 +1018,9 @@ class Plugin(object):
|
|
|
30f6f4 |
"""Execute a command and save the output to a file for inclusion in the
|
|
|
30f6f4 |
report.
|
|
|
30f6f4 |
"""
|
|
|
30f6f4 |
+ if self._timeout_hit:
|
|
|
30f6f4 |
+ return
|
|
|
30f6f4 |
+
|
|
|
30f6f4 |
start = time()
|
|
|
30f6f4 |
|
|
|
30f6f4 |
result = self.get_command_output(exe, timeout=timeout, stderr=stderr,
|
|
|
30f6f4 |
@@ -1201,6 +1210,8 @@ class Plugin(object):
|
|
|
30f6f4 |
|
|
|
30f6f4 |
def _collect_strings(self):
|
|
|
30f6f4 |
for string, file_name in self.copy_strings:
|
|
|
30f6f4 |
+ if self._timeout_hit:
|
|
|
30f6f4 |
+ return
|
|
|
30f6f4 |
content = ''
|
|
|
30f6f4 |
if string:
|
|
|
30f6f4 |
content = string.splitlines()[0]
|
|
|
30f6f4 |
--
|
|
|
30f6f4 |
2.21.0
|
|
|
30f6f4 |
|