aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2020-03-06 11:52:14 -0500
committerJake Hunsaker <jhunsake@redhat.com>2020-03-18 09:38:42 -0400
commitc03dcee177187c073a6fb0b48acda2c4ea2e0ff4 (patch)
treeb4a4370f63b21ba396b8ff852fc6c87093c08f52
parentf7469b2f316281c49e574467e41002f4b479b082 (diff)
downloadsos-c03dcee177187c073a6fb0b48acda2c4ea2e0ff4.tar.gz
[Plugin] Do not write empty files to archive on command failure
If a command is not found on the system, sos traditionally will handle that failed call by simply not writing any output to the archive. However, if the command was given a suggested_filename or a root_symlink parameter in the `add_cmd_output()` call, we would end up writing an empty file to the archive. Now, we will re-check the status of the command attempt after the chroot check (and possible re-run) is done, and if the command "still" is not found, exit immediately to avoid the empty writes. Related: #1975 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/plugins/__init__.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 7f1b5ea2..76a85541 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -1256,6 +1256,10 @@ class Plugin(object):
poller=self.check_timeout
)
self._log_debug("could not run '%s': command not found" % cmd)
+ # Exit here if the command was not found in the chroot check above
+ # as otherwise we will create a blank file in the archive
+ if result['status'] in [126, 127]:
+ return result
self._log_debug("collected output of '%s' in %s (changes=%s)"
% (cmd.split()[0], time() - start, changes))