[proxy] print all stderr from callWeave to the proxy logs, even if successful
This commit is contained in:
1 parent
fcea6fcbf8
commit
7821412bf7
3 files changed
+13
-8
No files matched your search
+6
-3
@@ -18,13 +18,16 @@ var (
|
||||
weaveWaitEntrypoint = []string{"/w/w"}
|
||||
)
|
||||
|
||||
func callWeave(args ...string) ([]byte, error) {
|
||||
func callWeave(args ...string) ([]byte, []byte, error) {
|
||||
args = append([]string{"--local"}, args...)
|
||||
Log.Debug("Calling weave", args)
|
||||
cmd := exec.Command("./weave", args...)
|
||||
cmd.Env = []string{"PROCFS=/hostproc", "PATH=/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}
|
||||
out, err := cmd.CombinedOutput()
|
||||
return out, err
|
||||
var stdout, stderr bytes.Buffer
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
err := cmd.Run()
|
||||
return stdout.Bytes(), stderr.Bytes(), err
|
||||
}
|
||||
|
||||
func marshalRequestBody(r *http.Request, body interface{}) error {
|
||||
|
||||
+2
-2
@@ -57,9 +57,9 @@ func NewProxy(c Config) (*Proxy, error) {
|
||||
p.client = client
|
||||
|
||||
if !p.WithoutDNS {
|
||||
dockerBridgeIP, err := callWeave("docker-bridge-ip")
|
||||
dockerBridgeIP, stderr, err := callWeave("docker-bridge-ip")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf(string(stderr))
|
||||
}
|
||||
p.dockerBridgeIP = string(dockerBridgeIP)
|
||||
}
|
||||
|
||||
@@ -30,9 +30,11 @@ func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
|
||||
args := []string{"attach"}
|
||||
args = append(args, cidrs...)
|
||||
args = append(args, "--or-die", container.ID)
|
||||
if output, err := callWeave(args...); err != nil {
|
||||
Log.Warningf("Attaching container %s to weave network failed: %s", container.ID, string(output))
|
||||
return errors.New(string(output))
|
||||
if _, stderr, err := callWeave(args...); err != nil {
|
||||
Log.Warningf("Attaching container %s to weave network failed: %s", container.ID, string(stderr))
|
||||
return errors.New(string(stderr))
|
||||
} else if len(stderr) > 0 {
|
||||
Log.Warningf("Attaching container %s to weave network: %s", container.ID, string(stderr))
|
||||
}
|
||||
|
||||
return i.proxy.client.KillContainer(docker.KillContainerOptions{ID: container.ID, Signal: docker.SIGUSR2})
|
||||
|
||||
Reference in new issue
Block a user