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

Commit

Permalink
Merge pull request #1067 from paulbellamy/proxy-stderr
Browse files Browse the repository at this point in the history
print all stderr output from callWeave to the proxy logs, even if successful

Closes #1056
  • Loading branch information
rade committed Jul 4, 2015
2 parents 910b577 + 7821412 commit b30de63
Show file tree
Hide file tree
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
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 5 additions & 3 deletions proxy/start_container_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit b30de63

Please sign in to comment.