[proxy] Add support for WEAVE_CIDR=none

Tells the proxy not to do anything with this container. We set it when
running weaveexec/weave/etc containers, so that the weave script works
through the proxy.
This commit is contained in:
Paul Bellamy committed 2015-06-17 14:51:12 +01:00
1 parent ff838a14d9
commit ca681bce13
8 files changed
+44 -15

No files matched your search

+5 -2
View File
@@ -28,13 +28,16 @@ func callWeave(args ...string) ([]byte, error) {
return out, err
}
func weaveCIDRsFromConfig(config *docker.Config) ([]string, bool) {
func weaveCIDRsFromConfig(config *docker.Config, noDefaultIPAM bool) ([]string, bool) {
for _, e := range config.Env {
if strings.HasPrefix(e, "WEAVE_CIDR=") {
if e[11:] == "none" {
return nil, false
}
return strings.Fields(e[11:]), true
}
}
return nil, false
return nil, !noDefaultIPAM
}
func marshalRequestBody(r *http.Request, body interface{}) error {
+1 -1
View File
@@ -33,7 +33,7 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error {
return err
}
if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || !i.proxy.NoDefaultIPAM {
if cidrs, ok := weaveCIDRsFromConfig(container.Config, i.proxy.NoDefaultIPAM); ok {
Info.Printf("Creating container with WEAVE_CIDR \"%s\"", strings.Join(cidrs, " "))
if container.HostConfig == nil {
container.HostConfig = &docker.HostConfig{}
+1 -1
View File
@@ -29,7 +29,7 @@ func (i *createExecInterceptor) InterceptRequest(r *http.Request) error {
return err
}
if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || !i.proxy.NoDefaultIPAM {
if cidrs, ok := weaveCIDRsFromConfig(container.Config, i.proxy.NoDefaultIPAM); ok {
Info.Printf("Exec in container %s with WEAVE_CIDR \"%s\"", container.ID, strings.Join(cidrs, " "))
cmd := append(weaveWaitEntrypoint, "-s")
options.Cmd = append(cmd, options.Cmd...)
+2 -2
View File
@@ -21,8 +21,8 @@ func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
return err
}
cidrs, ok := weaveCIDRsFromConfig(container.Config)
if !ok && i.proxy.NoDefaultIPAM {
cidrs, ok := weaveCIDRsFromConfig(container.Config, i.proxy.NoDefaultIPAM)
if !ok {
Debug.Print("No Weave CIDR, ignoring")
return nil
}