aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2019-08-26 18:23:21 +0200
committerPavel Moravec <pmoravec@redhat.com>2019-08-26 18:23:21 +0200
commit9c421f819fcb40877aa873719656b8b3b6590d06 (patch)
tree9ee8c2680e8cf223798b592df6151e9ba539cf85
parent1066dfe4a80acfb34a18cd63fb22b53dfd2cc18e (diff)
downloadsos-9c421f819fcb40877aa873719656b8b3b6590d06.tar.gz
[plugins] log when skipping files over size limit
Sosreport should log when skipping files due to sizelimit. That gives users valuable information about remaining files on the system. Resolves: #1719 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/plugins/__init__.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 9ca009df..5b76df2d 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -898,12 +898,15 @@ class Plugin(object):
files.sort(key=getmtime, reverse=True)
current_size = 0
limit_reached = False
- _file = None
for _file in files:
if self._is_forbidden_path(_file):
self._log_debug("skipping forbidden path '%s'" % _file)
continue
+ if limit_reached:
+ self._log_info("skipping '%s' over size limit" % _file)
+ continue
+
try:
filestat = os.stat(_file)
except OSError:
@@ -913,21 +916,24 @@ class Plugin(object):
if sizelimit and current_size > sizelimit:
limit_reached = True
- break
-
- self._add_copy_paths([_file])
-
- if limit_reached and tailit and not _file_is_compressed(_file):
- file_name = _file
- if file_name[0] == os.sep:
- file_name = file_name.lstrip(os.sep)
- strfile = file_name.replace(os.path.sep, ".") + ".tailed"
- self.add_string_as_file(tail(_file, sizelimit), strfile)
- rel_path = os.path.relpath('/', os.path.dirname(_file))
- link_path = os.path.join(rel_path, 'sos_strings',
- self.name(), strfile)
- self.archive.add_link(link_path, _file)
+ if tailit and not _file_is_compressed(_file):
+ self._log_info("collecting tail of '%s' due to size "
+ "limit" % _file)
+ file_name = _file
+ if file_name[0] == os.sep:
+ file_name = file_name.lstrip(os.sep)
+ strfile = file_name.replace(os.path.sep, ".") + ".tailed"
+ self.add_string_as_file(tail(_file, sizelimit), strfile)
+ rel_path = os.path.relpath('/', os.path.dirname(_file))
+ link_path = os.path.join(rel_path, 'sos_strings',
+ self.name(), strfile)
+ self.archive.add_link(link_path, _file)
+ else:
+ self._log_info("skipping '%s' over size limit" % _file)
+ else:
+ # size limit not hit, copy the file
+ self._add_copy_paths([_file])
def get_command_output(self, prog, timeout=300, stderr=True,
chroot=True, runat=None, env=None,