From 6de3fabc9f758ead5a7602039d63df6ccd2ba577 Mon Sep 17 00:00:00 2001 From: "Izaak Alpert (karlhungus)" Date: Thu, 15 Sep 2022 14:31:24 -0400 Subject: [PATCH] output stdout and stderr from custom commands --- pkg/healthchecker/health_checker.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/healthchecker/health_checker.go b/pkg/healthchecker/health_checker.go index 1273ff99..ad6615bb 100644 --- a/pkg/healthchecker/health_checker.go +++ b/pkg/healthchecker/health_checker.go @@ -167,10 +167,11 @@ func execCommand(timeout time.Duration, command string, args ...string) (string, ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() cmd := exec.CommandContext(ctx, command, args...) - out, err := cmd.Output() + out, err := cmd.CombinedOutput() if err != nil { glog.Infof("command %v failed: %v, %v\n", cmd, err, out) return "", err } + return strings.TrimSuffix(string(out), "\n"), nil }