Merge pull request #820 from paulbellamy/weavewait-race-condition
Use USR2 signal to tell weavewait when to continue Fixes #812.
This commit is contained in:
commit
04c10233f7
3 files changed
+19
-9
No files matched your search
@@ -40,7 +40,7 @@ travis: $(EXES)
|
|||||||
update: $(EXES)
|
update: $(EXES)
|
||||||
go get -u -f -v -tags -netgo $(addprefix ./,$(dir $(EXES)))
|
go get -u -f -v -tags -netgo $(addprefix ./,$(dir $(EXES)))
|
||||||
|
|
||||||
$(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE): common/*.go common/*/*.go net/*.go
|
$(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVEPROXY_EXE): common/*.go common/*/*.go net/*.go
|
||||||
go get -tags netgo ./$(@D)
|
go get -tags netgo ./$(@D)
|
||||||
go build -ldflags "-extldflags \"-static\" -X main.version $(WEAVE_VERSION)" -tags netgo -o $@ ./$(@D)
|
go build -ldflags "-extldflags \"-static\" -X main.version $(WEAVE_VERSION)" -tags netgo -o $@ ./$(@D)
|
||||||
@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
|
@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
|
||||||
@@ -55,13 +55,16 @@ $(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE): common/*.go co
|
|||||||
$(WEAVER_EXE): router/*.go ipam/*.go ipam/*/*.go prog/weaver/main.go
|
$(WEAVER_EXE): router/*.go ipam/*.go ipam/*/*.go prog/weaver/main.go
|
||||||
$(WEAVEDNS_EXE): nameserver/*.go prog/weavedns/main.go
|
$(WEAVEDNS_EXE): nameserver/*.go prog/weavedns/main.go
|
||||||
$(WEAVEPROXY_EXE): proxy/*.go prog/weaveproxy/main.go
|
$(WEAVEPROXY_EXE): proxy/*.go prog/weaveproxy/main.go
|
||||||
$(WEAVEWAIT_EXE): prog/weavewait/*.go
|
|
||||||
|
|
||||||
# Sigproxy needs separate rule as it fails the netgo check in the main
|
# Sigproxy and weavewait need separate rules as they fail the netgo check in
|
||||||
# build stanza due to not importing net package
|
# the main build stanza due to not importing net package
|
||||||
|
|
||||||
$(SIGPROXY_EXE): prog/sigproxy/main.go
|
$(SIGPROXY_EXE): prog/sigproxy/main.go
|
||||||
go build -o $@ ./$(@D)
|
go build -o $@ ./$(@D)
|
||||||
|
|
||||||
|
$(WEAVEWAIT_EXE): prog/weavewait/main.go
|
||||||
|
go build -o $@ ./$(@D)
|
||||||
|
|
||||||
$(WEAVER_EXPORT): prog/weaver/Dockerfile $(WEAVER_EXE)
|
$(WEAVER_EXPORT): prog/weaver/Dockerfile $(WEAVER_EXE)
|
||||||
$(SUDO) docker build -t $(WEAVER_IMAGE) prog/weaver
|
$(SUDO) docker build -t $(WEAVER_IMAGE) prog/weaver
|
||||||
$(SUDO) docker save $(WEAVER_IMAGE):latest > $@
|
$(SUDO) docker save $(WEAVER_IMAGE):latest > $@
|
||||||
|
|||||||
+10
-4
@@ -1,17 +1,23 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
"github.com/weaveworks/weave/net"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
_, err := net.EnsureInterface("ethwe", 20)
|
usr2 := make(chan os.Signal)
|
||||||
checkErr(err)
|
signal.Notify(usr2, syscall.SIGUSR2)
|
||||||
|
select {
|
||||||
|
case <-usr2:
|
||||||
|
case <-time.After(20 * time.Second):
|
||||||
|
checkErr(errors.New("Container timed out waiting for signal from proxy"))
|
||||||
|
}
|
||||||
|
|
||||||
if len(os.Args) <= 1 {
|
if len(os.Args) <= 1 {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|||||||
@@ -39,5 +39,6 @@ func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error {
|
|||||||
Warning.Printf("Attaching container %s to weave network failed: %s", container.ID, string(output))
|
Warning.Printf("Attaching container %s to weave network failed: %s", container.ID, string(output))
|
||||||
return errors.New(string(output))
|
return errors.New(string(output))
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
return i.client.KillContainer(docker.KillContainerOptions{ID: container.ID, Signal: docker.SIGUSR2})
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user