Merge remote-tracking branch 'upstream/0.11' into 0.11

This commit is contained in:
Matthias Radestock committed 2015-05-31 11:54:08 +01:00
commit 158fb36c8c
3 files changed
+15 -12

No files matched your search

+2 -2
View File
@@ -35,7 +35,7 @@ func (c *client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case err == docker.ErrNoSuchImage: case err == docker.ErrNoSuchImage:
http.Error(w, err.Error(), http.StatusNotFound) http.Error(w, err.Error(), http.StatusNotFound)
default: default:
http.Error(w, "Unable to intercept request", http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
Warning.Print("Error intercepting request: ", err) Warning.Print("Error intercepting request: ", err)
} }
return return
@@ -58,7 +58,7 @@ func (c *client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
err = c.InterceptResponse(resp) err = c.InterceptResponse(resp)
if err != nil { if err != nil {
http.Error(w, "Unable to intercept response", http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
Warning.Print("Error intercepting response: ", err) Warning.Print("Error intercepting response: ", err)
return return
} }
+5 -2
View File
@@ -1,6 +1,7 @@
package proxy package proxy
import ( import (
"errors"
"net/http" "net/http"
"strings" "strings"
@@ -33,8 +34,10 @@ func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
args := []string{"attach"} args := []string{"attach"}
args = append(args, cidrs...) args = append(args, cidrs...)
args = append(args, container.ID) args = append(args, container.ID)
if _, err := callWeave(args...); err != nil { if output, err := callWeave(args...); err != nil {
Warning.Printf("Attaching container %s to weave network failed: %v", container.ID, err) i.client.KillContainer(docker.KillContainerOptions{ID: container.ID})
Warning.Printf("Attaching container %s to weave network failed: %s", container.ID, string(output))
return errors.New(string(output))
} }
return nil return nil
} }
+8 -8
View File
@@ -10,22 +10,22 @@ import (
) )
func main() { func main() {
if _, err := net.EnsureInterface("ethwe", 20); err != nil { _, err := net.EnsureInterface("ethwe", 20)
fmt.Fprintln(os.Stderr, err) checkErr(err)
}
if len(os.Args) <= 1 { if len(os.Args) <= 1 {
os.Exit(0) os.Exit(0)
} }
binary, err := exec.LookPath(os.Args[1]) binary, err := exec.LookPath(os.Args[1])
checkErr(err)
checkErr(syscall.Exec(binary, os.Args[1:], os.Environ()))
}
func checkErr(err error) {
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
os.Exit(1) os.Exit(1)
} }
if err := syscall.Exec(binary, os.Args[1:], os.Environ()); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
} }