Get the proxy to re-attach the weave router if it sees it restart
This commit is contained in:
1 parent
5ff740cddc
commit
a87cc5c3b1
3 files changed
+49
-2
No files matched your search
@@ -305,6 +305,8 @@ func (proxy *Proxy) ContainerStarted(ident string) {
|
||||
// If this was a container we modified the entrypoint for, attach it to the network
|
||||
if containerShouldAttach(container) {
|
||||
proxy.attach(container, true)
|
||||
} else if containerIsWeaveRouter(container) {
|
||||
proxy.attachRouter(container)
|
||||
}
|
||||
proxy.notifyWaiters(container.ID)
|
||||
}
|
||||
@@ -313,6 +315,10 @@ func containerShouldAttach(container *docker.Container) bool {
|
||||
return len(container.Config.Entrypoint) > 0 && container.Config.Entrypoint[0] == weaveWaitEntrypoint[0]
|
||||
}
|
||||
|
||||
func containerIsWeaveRouter(container *docker.Container) bool {
|
||||
return strings.HasPrefix(container.Config.Image, "weaveworks/weave")
|
||||
}
|
||||
|
||||
func (proxy *Proxy) createWait(r *http.Request, ident string) {
|
||||
proxy.Lock()
|
||||
ch := make(chan struct{})
|
||||
@@ -386,6 +392,18 @@ func (proxy *Proxy) attach(container *docker.Container, orDie bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (proxy *Proxy) attachRouter(container *docker.Container) error {
|
||||
Log.Infof("Attaching weave router container")
|
||||
args := []string{"attach-router"}
|
||||
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 {
|
||||
Log.Warningf("Attaching container %s to weave network: %s", container.ID, string(stderr))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (proxy *Proxy) weaveCIDRs(networkMode string, env []string) ([]string, error) {
|
||||
if networkMode == "host" || strings.HasPrefix(networkMode, "container:") {
|
||||
return nil, fmt.Errorf("the container was created with the '--net=%s'", networkMode)
|
||||
|
||||
Reference in new issue
Block a user