Fix status issue with none driver where CombinedOutput was causing errors

pull/1860/head
Aaron Prindle 2017-08-21 16:31:50 -07:00
parent 1052ff77bd
commit 99d8237f8b
2 changed files with 16 additions and 6 deletions

View File

@ -17,6 +17,7 @@ limitations under the License.
package cluster
import (
"bytes"
"encoding/json"
"flag"
"fmt"
@ -602,11 +603,15 @@ func RunCommand(h *host.Host, command string, sudo bool) (string, error) {
if sudo {
cmd = exec.Command("sudo", "/bin/bash", "-c", command)
}
out, err := cmd.CombinedOutput()
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
return "", errors.Wrap(err, string(out))
return "", errors.Wrap(err, stderr.String())
}
return string(out), err
return out.String(), err
}
out, err := h.RunSSHCommand(command)
if err != nil {

View File

@ -17,6 +17,7 @@ limitations under the License.
package none
import (
"bytes"
"fmt"
"os"
"os/exec"
@ -199,9 +200,13 @@ func runCommand(command string, sudo bool) (string, error) {
if sudo {
cmd = exec.Command("sudo", "/bin/bash", "-c", command)
}
out, err := cmd.CombinedOutput()
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
return "", errors.Wrap(err, string(out))
return "", errors.Wrap(err, stderr.String())
}
return string(out), nil
return out.String(), nil
}