allocatord: include vkube stout/stderr in error
When vkube invocation gives an error, say due to the invoking user not
having appropriate IAM permissions, then include the stdout/stderr in
the Go error to allow easier diagnosis of the problem.
Change-Id: I27c8ba4f4de36b5457981dfc2df8e86cda7fc339
diff --git a/services/allocator/allocatord/service.go b/services/allocator/allocatord/service.go
index 4caf82b..2c038e6 100644
--- a/services/allocator/allocatord/service.go
+++ b/services/allocator/allocatord/service.go
@@ -9,6 +9,7 @@
"encoding/base64"
"encoding/hex"
"encoding/json"
+ "fmt"
"io/ioutil"
"os"
"os/exec"
@@ -396,7 +397,7 @@
return exec.Command(gcloudBinFlag, args...).CombinedOutput()
}
-func vkube(args ...string) ([]byte, error) {
+func vkube(args ...string) (out []byte, err error) {
args = append(
[]string{
"--config=" + vkubeCfgFlag,
@@ -405,5 +406,9 @@
},
args...,
)
- return exec.Command(vkubeBinFlag, args...).CombinedOutput()
+ out, err = exec.Command(vkubeBinFlag, args...).CombinedOutput()
+ if err != nil {
+ err = fmt.Errorf("vkube(%v) failed: %v\n%s\n", args, err, string(out))
+ }
+ return
}