aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Bouchard <louis.bouchard@canonical.com>2017-05-10 14:19:56 +0200
committerAdam Stokes <battlemidget@users.noreply.github.com>2017-05-10 08:19:56 -0400
commitc1288230f29d334687827b8367ec58ef79b7e6fe (patch)
treeea02a0f321ac07ffbb1ded6c0b484104552dbc48
parente64e6407819926e305083ecc9f9c5372d97cd17a (diff)
downloadsos-c1288230f29d334687827b8367ec58ef79b7e6fe.tar.gz
[plugins] Handle stat errors on missing files (#991)
When the stat is done on a broken symlink, it will return either OSError or FileNotFoundError. Handle these and report accordingly. Signed-off-by: Louis Bouchard <louis.bouchard@canonical.com> Signed-off-by: Adam Stokes <battlemidget@users.noreply.github.com>
-rw-r--r--sos/plugins/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index cd34d196..2a779431 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -542,7 +542,10 @@ class Plugin(object):
_file = None
for _file in files:
- current_size += os.stat(_file)[stat.ST_SIZE]
+ try:
+ current_size += os.stat(_file)[stat.ST_SIZE]
+ except (OSError, FileNotFoundError):
+ self._log_info("failed to stat '%s'" % _file)
if sizelimit and current_size > sizelimit:
limit_reached = True
break