Update libcontainerd.AddProcess to accept a context

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
(cherry picked from commit c02f82756e)
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-07-15 14:12:07 -07:00 committed by Tibor Vass
parent b7687cc673
commit afc64c2d71
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"
)
@ -169,8 +171,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