Merge pull request #6395 from leseb/log-err-exec-file

ceph: log stderr in error when exec with output file
This commit is contained in:
Sébastien Han authored and GitHub committed 2020-10-08 17:56:00 +02:00
commit fe6b321bc6
1 file changed
+3
+3
View File
@@ -199,6 +199,9 @@ func (*CommandExecutor) ExecuteCommandWithOutputFile(command, outfileArg string,
// #nosec G204 Rook controls the input to the exec arguments
cmd := exec.Command(command, arg...)
cmdOut, err := cmd.CombinedOutput()
if err != nil {
cmdOut = []byte(fmt.Sprintf("%s. %s", string(cmdOut), string(err.(*exec.ExitError).Stderr)))
}
// if there was anything that went to stdout/stderr then log it, even before we return an error
if string(cmdOut) != "" {
logger.Debug(string(cmdOut))