Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixup! Proxy observes WEAVE_NO_MULTICAST_ROUTE
  • Loading branch information
awh committed Dec 10, 2015
1 parent 4629bdf commit b91b31f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
1 change: 1 addition & 0 deletions prog/weaveproxy/main.go
Expand Up @@ -40,6 +40,7 @@ func main() {
mflag.BoolVar(&c.TLSConfig.Verify, []string{"#tlsverify", "-tlsverify"}, false, "Use TLS and verify the remote")
mflag.BoolVar(&c.WithDNS, []string{"-with-dns", "w"}, false, "instruct created containers to always use weaveDNS as their nameserver")
mflag.BoolVar(&c.WithoutDNS, []string{"-without-dns"}, false, "instruct created containers to never use weaveDNS as their nameserver")
mflag.BoolVar(&c.NoMulticastRoute, []string{"-no-multicast-route"}, false, "do not add a multicast route via the weave interface when attaching containers")
mflag.Parse()

if justVersion {
Expand Down
8 changes: 2 additions & 6 deletions proxy/common.go
Expand Up @@ -25,16 +25,12 @@ var (
)

func callWeave(args ...string) ([]byte, []byte, error) {
return callWeaveEnv(nil, args...)
}

func callWeaveEnv(env []string, args ...string) ([]byte, []byte, error) {
args = append([]string{"--local"}, args...)
cmd := exec.Command("./weave", args...)
cmd.Env = append([]string{
cmd.Env = []string{
"PATH=/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"PROCFS=/hostproc",
}, env...)
}

propagateEnv := func(key string) {
if val := os.Getenv(key); val != "" {
Expand Down
16 changes: 5 additions & 11 deletions proxy/proxy.go
Expand Up @@ -60,6 +60,7 @@ type Config struct {
Version string
WithDNS bool
WithoutDNS bool
NoMulticastRoute bool
}

type wait struct {
Expand Down Expand Up @@ -430,11 +431,14 @@ func (proxy *Proxy) attach(container *docker.Container, orDie bool) error {
}
}
}
if proxy.NoMulticastRoute {
args = append(args, "--no-multicast-route")
}
if orDie {
args = append(args, "--or-die")
}
args = append(args, container.ID)
if _, stderr, err := callWeaveEnv(weaveAttachEnv(container), args...); err != nil {
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 {
Expand All @@ -456,16 +460,6 @@ func (proxy *Proxy) attachRouter(container *docker.Container) error {
return nil
}

func weaveAttachEnv(container *docker.Container) []string {
attachEnv := []string{}
for _, e := range container.Config.Env {
if strings.HasPrefix(e, "WEAVE_NO_MULTICAST_ROUTE=") {
attachEnv = append(attachEnv, e)
}
}
return attachEnv
}

func (proxy *Proxy) weaveCIDRs(networkMode string, env []string) ([]string, error) {
if networkMode == "host" || strings.HasPrefix(networkMode, "container:") {
return nil, fmt.Errorf("the container has '--net=%s'", networkMode)
Expand Down

0 comments on commit b91b31f

Please sign in to comment.