aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2017-08-31 12:48:43 +0100
committerBryn M. Reeves <bmr@redhat.com>2017-08-31 13:37:48 +0100
commit7ef429d61a46fda36a84a1340659ce05131be43b (patch)
tree360d468f53d05e9edd8bab6e6f6f846f2ad1e8bb
parentb8d0daf78a3f87e7c98d77be769fdf3c5f31ae20 (diff)
downloadsos-7ef429d61a46fda36a84a1340659ce05131be43b.tar.gz
[Plugin] fix bogus 're-trying in host root' messages
If a command is not found in Plugin.get_command_output() and the run is not configured to use an alternate sysroot (either via policy based autodetection or command line --sysroot=/path) the plugin would log messages like: [plugin:gluster] command 'gluster' not found in / - re-trying in host root This is incorrect: without an alternate sysroot the attempt should fail immediately at this point (since the 'retry' will attempt to find the command in the same namespace). This is caused by an incorrect test for alternate sysroot: if chroot and self.commons['cmdlineopts'].chroot != 'always': The 'chroot' variable is always True here, unless the caller has explicitly disabled it, or we are re-trying a command in a run with an alternate sysroot defined. Instead test that 'root' is not None and that it is not equal to '/'. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 2d6f6ff5..f24f27ea 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -582,13 +582,14 @@ class Plugin(object):
# command not found or not runnable
if result['status'] == 126 or result['status'] == 127:
# automatically retry chroot'ed commands in the host namespace
- if chroot and self.commons['cmdlineopts'].chroot != 'always':
- self._log_info("command '%s' not found in %s - "
- "re-trying in host root"
- % (prog.split()[0], root))
- return self.get_command_output(prog, timeout=timeout,
- chroot=False, runat=runat,
- env=env)
+ if root and root != '/':
+ if self.commons['cmdlineopts'].chroot != 'always':
+ self._log_info("command '%s' not found in %s - "
+ "re-trying in host root"
+ % (prog.split()[0], root))
+ return self.get_command_output(prog, timeout=timeout,
+ chroot=False, runat=runat,
+ env=env)
self._log_debug("could not run '%s': command not found" % prog)
return result