Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
[proxy] print all stderr from callWeave to the proxy logs, even if su…
Browse files Browse the repository at this point in the history
…ccessful
paulbellamy committed Jul 3, 2015

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent fcea6fc commit 7821412
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 6 additions & 3 deletions proxy/common.go
Original file line number Diff line number Diff line change
@@ -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 {
4 changes: 2 additions & 2 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
@@ -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)
}
8 changes: 5 additions & 3 deletions proxy/start_container_interceptor.go
Original file line number Diff line number Diff line change
@@ -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})

0 comments on commit 7821412

Please sign in to comment.