|
|
e75bc7 |
From 95bb5df9eda253afed15fa81340d31e03c40fe94 Mon Sep 17 00:00:00 2001
|
|
|
e75bc7 |
From: "Bryn M. Reeves" <bmr@redhat.com>
|
|
|
e75bc7 |
Date: Tue, 13 Jan 2015 17:10:06 +0000
|
|
|
e75bc7 |
Subject: [PATCH] [sosreport] catch OSError exceptions in SoSReport.execute()
|
|
|
e75bc7 |
|
|
|
e75bc7 |
OSError exceptions during logging setup and tear down are not
|
|
|
e75bc7 |
currently handled:
|
|
|
e75bc7 |
|
|
|
e75bc7 |
Traceback (most recent call last):
|
|
|
e75bc7 |
File "/usr/sbin/sosreport", line 25, in <module>
|
|
|
e75bc7 |
main(sys.argv[1:])
|
|
|
e75bc7 |
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1409, in main
|
|
|
e75bc7 |
sos.execute()
|
|
|
e75bc7 |
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1366, in execute
|
|
|
e75bc7 |
self._setup_logging()
|
|
|
e75bc7 |
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 739, in _setup_logging
|
|
|
e75bc7 |
self.sos_log_file = self.get_temp_file()
|
|
|
e75bc7 |
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 670, in get_temp_file
|
|
|
e75bc7 |
return self.tempfile_util.new()
|
|
|
e75bc7 |
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 82, in new
|
|
|
e75bc7 |
fd, fname = tempfile.mkstemp(dir=self.tmp_dir)
|
|
|
e75bc7 |
File "/usr/lib64/python2.7/tempfile.py", line 304, in mkstemp
|
|
|
e75bc7 |
return _mkstemp_inner(dir, prefix, suffix, flags)
|
|
|
e75bc7 |
File "/usr/lib64/python2.7/tempfile.py", line 239, in _mkstemp_inner
|
|
|
e75bc7 |
fd = _os.open(file, flags, 0600)
|
|
|
e75bc7 |
OSError: [Errno 28] No space left on device: '/tmp/tmp.4ejNitjwcr/nospace_tmp/tmpBjPTOm'
|
|
|
e75bc7 |
|
|
|
e75bc7 |
Address this by adding OSError to the list of caught exceptions
|
|
|
e75bc7 |
in the main SoSReport.execute() method. Wrap the exception branch
|
|
|
e75bc7 |
clean up in a try/except block to catch additional exceptions
|
|
|
e75bc7 |
while attempting to clean up (e.g. unlink failures following an
|
|
|
e75bc7 |
EROFS on the temporary archive path).
|
|
|
e75bc7 |
|
|
|
e75bc7 |
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
|
|
|
e75bc7 |
---
|
|
|
e75bc7 |
sos/sosreport.py | 19 +++++++++++++------
|
|
|
e75bc7 |
1 file changed, 13 insertions(+), 6 deletions(-)
|
|
|
e75bc7 |
|
|
|
e75bc7 |
diff --git a/sos/sosreport.py b/sos/sosreport.py
|
|
|
e75bc7 |
index 0dd26ad..2a16555 100644
|
|
|
e75bc7 |
--- a/sos/sosreport.py
|
|
|
e75bc7 |
+++ b/sos/sosreport.py
|
|
|
e75bc7 |
@@ -1395,12 +1395,19 @@ class SoSReport(object):
|
|
|
e75bc7 |
self.version()
|
|
|
e75bc7 |
|
|
|
e75bc7 |
return self.final_work()
|
|
|
e75bc7 |
- except (SystemExit, KeyboardInterrupt):
|
|
|
e75bc7 |
- if self.archive:
|
|
|
e75bc7 |
- self.archive.cleanup()
|
|
|
e75bc7 |
- if self.tempfile_util:
|
|
|
e75bc7 |
- self.tempfile_util.clean()
|
|
|
e75bc7 |
- return False
|
|
|
e75bc7 |
+
|
|
|
e75bc7 |
+ except (OSError, SystemExit, KeyboardInterrupt):
|
|
|
e75bc7 |
+ try:
|
|
|
e75bc7 |
+ # archive and tempfile cleanup may fail due to a fatal
|
|
|
e75bc7 |
+ # OSError exception (ENOSPC, EROFS etc.).
|
|
|
e75bc7 |
+ if self.archive:
|
|
|
e75bc7 |
+ self.archive.cleanup()
|
|
|
e75bc7 |
+ if self.tempfile_util:
|
|
|
e75bc7 |
+ self.tempfile_util.clean()
|
|
|
e75bc7 |
+ except:
|
|
|
e75bc7 |
+ pass
|
|
|
e75bc7 |
+
|
|
|
e75bc7 |
+ return False
|
|
|
e75bc7 |
|
|
|
e75bc7 |
|
|
|
e75bc7 |
def main(args):
|
|
|
e75bc7 |
--
|
|
|
e75bc7 |
1.9.3
|
|
|
e75bc7 |
|