Blame SOURCES/sos-bz1733469-timeouted-plugin-stop-further-collection.patch

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