1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Update libcontainerd.AddProcess to accept a context

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-07-15 14:12:07 -07:00
parent 64483c3bda
commit c02f82756e
5 changed files with 16 additions and 9 deletions

View file

@ -199,12 +199,12 @@ func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.R
}
if err := execSetPlatformOpt(c, ec, &p); err != nil {
return nil
return err
}
attachErr := container.AttachStreams(ctx, ec.StreamConfig, ec.OpenStdin, true, ec.Tty, cStdin, cStdout, cStderr, ec.DetachKeys)
if err := d.containerd.AddProcess(c.ID, name, p); err != nil {
if err := d.containerd.AddProcess(ctx, c.ID, name, p); err != nil {
return err
}

View file

@ -28,7 +28,7 @@ type client struct {
liveRestore bool
}
func (clnt *client) AddProcess(containerID, processFriendlyName string, specp Process) error {
func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process) error {
clnt.lock(containerID)
defer clnt.unlock(containerID)
container, err := clnt.getContainer(containerID)
@ -89,7 +89,7 @@ func (clnt *client) AddProcess(containerID, processFriendlyName string, specp Pr
return err
}
if _, err := clnt.remote.apiClient.AddProcess(context.Background(), r); err != nil {
if _, err := clnt.remote.apiClient.AddProcess(ctx, r); err != nil {
p.closeFifos(iopipe)
return err
}

View file

@ -1,12 +1,14 @@
package libcontainerd
import "golang.org/x/net/context"
type client struct {
clientCommon
// Platform specific properties below here.
}
func (clnt *client) AddProcess(containerID, processFriendlyName string, specp Process) error {
func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process) error {
return nil
}

View file

@ -8,6 +8,8 @@ import (
"strings"
"syscall"
"golang.org/x/net/context"
"github.com/Microsoft/hcsshim"
"github.com/Sirupsen/logrus"
)
@ -176,8 +178,7 @@ func (clnt *client) Create(containerID string, spec Spec, options ...CreateOptio
// AddProcess is the handler for adding a process to an already running
// container. It's called through docker exec.
func (clnt *client) AddProcess(containerID, processFriendlyName string, procToAdd Process) error {
func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, procToAdd Process) error {
clnt.lock(containerID)
defer clnt.unlock(containerID)
container, err := clnt.getContainer(containerID)

View file

@ -1,6 +1,10 @@
package libcontainerd
import "io"
import (
"io"
"golang.org/x/net/context"
)
// State constants used in state change reporting.
const (
@ -35,7 +39,7 @@ type Client interface {
Create(containerID string, spec Spec, options ...CreateOption) error
Signal(containerID string, sig int) error
SignalProcess(containerID string, processFriendlyName string, sig int) error
AddProcess(containerID, processFriendlyName string, process Process) error
AddProcess(ctx context.Context, containerID, processFriendlyName string, process Process) error
Resize(containerID, processFriendlyName string, width, height int) error
Pause(containerID string) error
Resume(containerID string) error