Browse code

Update libcontainerd.AddProcess to accept a context

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

Kenfe-Mickael Laventure authored on 2016/07/16 06:12:07
Showing 5 changed files
... ...
@@ -199,12 +199,12 @@ func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.R
199 199
 	}
200 200
 
201 201
 	if err := execSetPlatformOpt(c, ec, &p); err != nil {
202
-		return nil
202
+		return err
203 203
 	}
204 204
 
205 205
 	attachErr := container.AttachStreams(ctx, ec.StreamConfig, ec.OpenStdin, true, ec.Tty, cStdin, cStdout, cStderr, ec.DetachKeys)
206 206
 
207
-	if err := d.containerd.AddProcess(c.ID, name, p); err != nil {
207
+	if err := d.containerd.AddProcess(ctx, c.ID, name, p); err != nil {
208 208
 		return err
209 209
 	}
210 210
 
... ...
@@ -28,7 +28,7 @@ type client struct {
28 28
 	liveRestore   bool
29 29
 }
30 30
 
31
-func (clnt *client) AddProcess(containerID, processFriendlyName string, specp Process) error {
31
+func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process) error {
32 32
 	clnt.lock(containerID)
33 33
 	defer clnt.unlock(containerID)
34 34
 	container, err := clnt.getContainer(containerID)
... ...
@@ -89,7 +89,7 @@ func (clnt *client) AddProcess(containerID, processFriendlyName string, specp Pr
89 89
 		return err
90 90
 	}
91 91
 
92
-	if _, err := clnt.remote.apiClient.AddProcess(context.Background(), r); err != nil {
92
+	if _, err := clnt.remote.apiClient.AddProcess(ctx, r); err != nil {
93 93
 		p.closeFifos(iopipe)
94 94
 		return err
95 95
 	}
... ...
@@ -1,12 +1,14 @@
1 1
 package libcontainerd
2 2
 
3
+import "golang.org/x/net/context"
4
+
3 5
 type client struct {
4 6
 	clientCommon
5 7
 
6 8
 	// Platform specific properties below here.
7 9
 }
8 10
 
9
-func (clnt *client) AddProcess(containerID, processFriendlyName string, specp Process) error {
11
+func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process) error {
10 12
 	return nil
11 13
 }
12 14
 
... ...
@@ -8,6 +8,8 @@ import (
8 8
 	"strings"
9 9
 	"syscall"
10 10
 
11
+	"golang.org/x/net/context"
12
+
11 13
 	"github.com/Microsoft/hcsshim"
12 14
 	"github.com/Sirupsen/logrus"
13 15
 )
... ...
@@ -176,8 +178,7 @@ func (clnt *client) Create(containerID string, spec Spec, options ...CreateOptio
176 176
 
177 177
 // AddProcess is the handler for adding a process to an already running
178 178
 // container. It's called through docker exec.
179
-func (clnt *client) AddProcess(containerID, processFriendlyName string, procToAdd Process) error {
180
-
179
+func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, procToAdd Process) error {
181 180
 	clnt.lock(containerID)
182 181
 	defer clnt.unlock(containerID)
183 182
 	container, err := clnt.getContainer(containerID)
... ...
@@ -1,6 +1,10 @@
1 1
 package libcontainerd
2 2
 
3
-import "io"
3
+import (
4
+	"io"
5
+
6
+	"golang.org/x/net/context"
7
+)
4 8
 
5 9
 // State constants used in state change reporting.
6 10
 const (
... ...
@@ -35,7 +39,7 @@ type Client interface {
35 35
 	Create(containerID string, spec Spec, options ...CreateOption) error
36 36
 	Signal(containerID string, sig int) error
37 37
 	SignalProcess(containerID string, processFriendlyName string, sig int) error
38
-	AddProcess(containerID, processFriendlyName string, process Process) error
38
+	AddProcess(ctx context.Context, containerID, processFriendlyName string, process Process) error
39 39
 	Resize(containerID, processFriendlyName string, width, height int) error
40 40
 	Pause(containerID string) error
41 41
 	Resume(containerID string) error