From afc64c2d71315d9629b1ad4659d5e5824a37f227 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Fri, 15 Jul 2016 14:12:07 -0700 Subject: [PATCH] Update libcontainerd.AddProcess to accept a context Signed-off-by: Kenfe-Mickael Laventure (cherry picked from commit c02f82756e914081543bf05cb1815a48c02b1ebd) Signed-off-by: Tibor Vass --- daemon/exec.go | 4 ++-- libcontainerd/client_linux.go | 4 ++-- libcontainerd/client_solaris.go | 4 +++- libcontainerd/client_windows.go | 5 +++-- libcontainerd/types.go | 8 ++++++-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/daemon/exec.go b/daemon/exec.go index b323222917..d57b6875d8 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -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 } diff --git a/libcontainerd/client_linux.go b/libcontainerd/client_linux.go index 5e4857e3ee..a1d9ca893c 100644 --- a/libcontainerd/client_linux.go +++ b/libcontainerd/client_linux.go @@ -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 } diff --git a/libcontainerd/client_solaris.go b/libcontainerd/client_solaris.go index ea8c5e1828..1c14d301b5 100644 --- a/libcontainerd/client_solaris.go +++ b/libcontainerd/client_solaris.go @@ -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 } diff --git a/libcontainerd/client_windows.go b/libcontainerd/client_windows.go index 7a43237b06..ce2b2b57d5 100644 --- a/libcontainerd/client_windows.go +++ b/libcontainerd/client_windows.go @@ -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) diff --git a/libcontainerd/types.go b/libcontainerd/types.go index 357ca1bd4d..6f452c1c3b 100644 --- a/libcontainerd/types.go +++ b/libcontainerd/types.go @@ -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