Due to https://github.com/docker/docker/issues/9098, there is no way to signal an exec. Instead we'll have to just poll the interface and hope. Adds `weavewait -s` which is the way to tell weavewait to skip waiting for a signal, which we use on execs
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
package proxy
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/fsouza/go-dockerclient"
|
|
. "github.com/weaveworks/weave/common"
|
|
)
|
|
|
|
type createExecInterceptor struct {
|
|
client *docker.Client
|
|
withIPAM bool
|
|
}
|
|
|
|
func (i *createExecInterceptor) InterceptRequest(r *http.Request) error {
|
|
body, err := ioutil.ReadAll(r.Body)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
r.Body.Close()
|
|
|
|
options := docker.CreateExecOptions{}
|
|
if err := json.Unmarshal(body, &options); err != nil {
|
|
return err
|
|
}
|
|
|
|
container, err := inspectContainerInPath(i.client, r.URL.Path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if cidrs, ok := weaveCIDRsFromConfig(container.Config); ok || i.withIPAM {
|
|
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...)
|
|
}
|
|
|
|
if err := marshalRequestBody(r, options); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (i *createExecInterceptor) InterceptResponse(r *http.Response) error {
|
|
return nil
|
|
}
|