浏览代码

Update libcontainerd.AddProcess to accept a context

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Kenfe-Mickael Laventure 9 年之前
父节点
当前提交
c02f82756e
共有 5 个文件被更改,包括 16 次插入9 次删除
  1. 2 2
      daemon/exec.go
  2. 2 2
      libcontainerd/client_linux.go
  3. 3 1
      libcontainerd/client_solaris.go
  4. 3 2
      libcontainerd/client_windows.go
  5. 6 2
      libcontainerd/types.go

+ 2 - 2
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 {
 	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)
 	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
 		return err
 	}
 	}
 
 

+ 2 - 2
libcontainerd/client_linux.go

@@ -28,7 +28,7 @@ type client struct {
 	liveRestore   bool
 	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)
 	clnt.lock(containerID)
 	defer clnt.unlock(containerID)
 	defer clnt.unlock(containerID)
 	container, err := clnt.getContainer(containerID)
 	container, err := clnt.getContainer(containerID)
@@ -89,7 +89,7 @@ func (clnt *client) AddProcess(containerID, processFriendlyName string, specp Pr
 		return err
 		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)
 		p.closeFifos(iopipe)
 		return err
 		return err
 	}
 	}

+ 3 - 1
libcontainerd/client_solaris.go

@@ -1,12 +1,14 @@
 package libcontainerd
 package libcontainerd
 
 
+import "golang.org/x/net/context"
+
 type client struct {
 type client struct {
 	clientCommon
 	clientCommon
 
 
 	// Platform specific properties below here.
 	// 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
 	return nil
 }
 }
 
 

+ 3 - 2
libcontainerd/client_windows.go

@@ -8,6 +8,8 @@ import (
 	"strings"
 	"strings"
 	"syscall"
 	"syscall"
 
 
+	"golang.org/x/net/context"
+
 	"github.com/Microsoft/hcsshim"
 	"github.com/Microsoft/hcsshim"
 	"github.com/Sirupsen/logrus"
 	"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
 // AddProcess is the handler for adding a process to an already running
 // container. It's called through docker exec.
 // 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)
 	clnt.lock(containerID)
 	defer clnt.unlock(containerID)
 	defer clnt.unlock(containerID)
 	container, err := clnt.getContainer(containerID)
 	container, err := clnt.getContainer(containerID)

+ 6 - 2
libcontainerd/types.go

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