proxy needs to add weavewait to execs as well

Bug came up in a test where we are restarting and doing an exec checking
a network interface right away. weavewait is only added if the container
has a WEAVE_CIDR var set, the same as at container creation.
This commit is contained in:
Paul Bellamy committed 2015-05-19 17:36:53 +01:00
1 parent 70b595c4a2
commit e6b587ea8d
7 files changed
+106 -18

No files matched your search

+5 -16
View File
@@ -2,15 +2,12 @@ package proxy
import (
"net/http"
"regexp"
"strings"
"github.com/fsouza/go-dockerclient"
. "github.com/weaveworks/weave/common"
)
var containerIDRegexp = regexp.MustCompile("^/v[0-9\\.]*/containers/([^/]*)/.*")
type startContainerInterceptor struct {
client *docker.Client
withDNS bool
@@ -21,17 +18,9 @@ func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error {
}
func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
subs := containerIDRegexp.FindStringSubmatch(r.Request.URL.Path)
if subs == nil {
Warning.Printf("No container id found in request with path %s", r.Request.URL.Path)
return nil
}
containerID := subs[1]
container, err := i.client.InspectContainer(containerID)
container, err := inspectContainerInPath(i.client, r.Request.URL.Path)
if err != nil {
Warning.Printf("Error inspecting container %s: %v", containerID, err)
return nil
return err
}
cidrs, ok := weaveCIDRsFromConfig(container.Config)
@@ -39,12 +28,12 @@ func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
Debug.Print("No Weave CIDR, ignoring")
return nil
}
Info.Printf("Container %s was started with CIDR \"%s\"", containerID, strings.Join(cidrs, " "))
Info.Printf("Container %s was started with CIDR \"%s\"", container.ID, strings.Join(cidrs, " "))
args := []string{"attach"}
args = append(args, cidrs...)
args = append(args, containerID)
args = append(args, container.ID)
if _, err := callWeave(args...); err != nil {
Warning.Printf("Attaching container %s to weave failed: %v", containerID, err)
Warning.Printf("Attaching container %s to weave failed: %v", container.ID, err)
return nil
}
return nil