|
|
8bcace |
From 15e54577289a29e72c636f8987859e91c3a55a7c Mon Sep 17 00:00:00 2001
|
|
|
8bcace |
From: Pavel Moravec <pmoravec@redhat.com>
|
|
|
8bcace |
Date: Thu, 10 Dec 2020 20:23:03 +0100
|
|
|
8bcace |
Subject: [PATCH] [report] collect broken symlinks
|
|
|
8bcace |
|
|
|
8bcace |
Information about broken symlink destination is useful information
|
|
|
8bcace |
that sos report should collect. Currently it stops doing so as
|
|
|
8bcace |
stat-ing the symlink to determine filesize fails.
|
|
|
8bcace |
|
|
|
8bcace |
Closes: #2333
|
|
|
8bcace |
Resolves: #2338
|
|
|
8bcace |
|
|
|
8bcace |
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
|
|
|
8bcace |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
8bcace |
---
|
|
|
8bcace |
sos/report/plugins/__init__.py | 16 ++++++++++------
|
|
|
8bcace |
1 file changed, 10 insertions(+), 6 deletions(-)
|
|
|
8bcace |
|
|
|
8bcace |
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
|
|
|
8bcace |
index 510e116e..1527caea 100644
|
|
|
8bcace |
--- a/sos/report/plugins/__init__.py
|
|
|
8bcace |
+++ b/sos/report/plugins/__init__.py
|
|
|
8bcace |
@@ -1449,11 +1449,16 @@ class Plugin(object):
|
|
|
8bcace |
continue
|
|
|
8bcace |
|
|
|
8bcace |
try:
|
|
|
8bcace |
- filestat = os.stat(_file)
|
|
|
8bcace |
+ file_size = os.stat(_file)[stat.ST_SIZE]
|
|
|
8bcace |
except OSError:
|
|
|
8bcace |
- self._log_info("failed to stat '%s'" % _file)
|
|
|
8bcace |
- continue
|
|
|
8bcace |
- current_size += filestat[stat.ST_SIZE]
|
|
|
8bcace |
+ # if _file is a broken symlink, we should collect it,
|
|
|
8bcace |
+ # otherwise skip it
|
|
|
8bcace |
+ if os.path.islink(_file):
|
|
|
8bcace |
+ file_size = 0
|
|
|
8bcace |
+ else:
|
|
|
8bcace |
+ self._log_info("failed to stat '%s', skipping" % _file)
|
|
|
8bcace |
+ continue
|
|
|
8bcace |
+ current_size += file_size
|
|
|
8bcace |
|
|
|
8bcace |
if sizelimit and current_size > sizelimit:
|
|
|
8bcace |
limit_reached = True
|
|
|
8bcace |
@@ -1467,8 +1472,7 @@ class Plugin(object):
|
|
|
8bcace |
strfile = (
|
|
|
8bcace |
file_name.replace(os.path.sep, ".") + ".tailed"
|
|
|
8bcace |
)
|
|
|
8bcace |
- add_size = (sizelimit + filestat[stat.ST_SIZE]
|
|
|
8bcace |
- - current_size)
|
|
|
8bcace |
+ add_size = sizelimit + file_size - current_size
|
|
|
8bcace |
self.add_string_as_file(tail(_file, add_size), strfile)
|
|
|
8bcace |
rel_path = os.path.relpath('/', os.path.dirname(_file))
|
|
|
8bcace |
link_path = os.path.join(rel_path, 'sos_strings',
|
|
|
8bcace |
--
|
|
|
8bcace |
2.26.2
|
|
|
8bcace |
|