From e775f2a03d3b3b83bd177ab0856e54fd3dce6af6 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 14 Dec 2018 15:41:41 -0500 Subject: [PATCH 1/2] Update containerd to aa5e000c963756778ab3ebd1a12c6 This includes a patch on top of containerd 1.2.1 to handle fifo timeouts. Signed-off-by: Michael Crosby (cherry picked from commit e5d9d721626958a37dccfa0b234d9fc96d8c2bfb) Signed-off-by: Andrew Hsu Upstream-commit: d161dfe1a36929a03ee3dfa916d296abfd4ccef1 Component: engine --- .../engine/hack/dockerfile/install/containerd.installer | 2 +- components/engine/vendor.conf | 2 +- .../containerd/containerd/runtime/v1/linux/proc/exec.go | 5 +++++ .../containerd/containerd/runtime/v1/linux/proc/init.go | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/engine/hack/dockerfile/install/containerd.installer b/components/engine/hack/dockerfile/install/containerd.installer index d0cebb8754..3300b2dbcf 100755 --- a/components/engine/hack/dockerfile/install/containerd.installer +++ b/components/engine/hack/dockerfile/install/containerd.installer @@ -4,7 +4,7 @@ # containerd is also pinned in vendor.conf. When updating the binary # version you may also need to update the vendor version to pick up bug # fixes or new APIs. -CONTAINERD_COMMIT=9b32062dc1f5a7c2564315c269b5059754f12b9d # v1.2.1 +CONTAINERD_COMMIT=aa5e000c963756778ab3ebd1a12c67449c503a34 # v1.2.1+ install_containerd() { echo "Install containerd version $CONTAINERD_COMMIT" diff --git a/components/engine/vendor.conf b/components/engine/vendor.conf index 24a2920ad2..42d3020c3b 100644 --- a/components/engine/vendor.conf +++ b/components/engine/vendor.conf @@ -118,7 +118,7 @@ github.com/googleapis/gax-go v2.0.0 google.golang.org/genproto 694d95ba50e67b2e363f3483057db5d4910c18f9 # containerd -github.com/containerd/containerd 9b32062dc1f5a7c2564315c269b5059754f12b9d # v1.2.1 +github.com/containerd/containerd aa5e000c963756778ab3ebd1a12c67449c503a34 # v1.2.1+ github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c github.com/containerd/continuity bd77b46c8352f74eb12c85bdc01f4b90f69d66b4 github.com/containerd/cgroups 5e610833b72089b37d0e615de9a92dfc043757c2 diff --git a/components/engine/vendor/github.com/containerd/containerd/runtime/v1/linux/proc/exec.go b/components/engine/vendor/github.com/containerd/containerd/runtime/v1/linux/proc/exec.go index 4c0e99e89c..cefce6cc3c 100644 --- a/components/engine/vendor/github.com/containerd/containerd/runtime/v1/linux/proc/exec.go +++ b/components/engine/vendor/github.com/containerd/containerd/runtime/v1/linux/proc/exec.go @@ -209,22 +209,27 @@ func (e *execProcess) start(ctx context.Context) (err error) { e.stdin = sc } var copyWaitGroup sync.WaitGroup + ctx, cancel := context.WithTimeout(ctx, 30*time.Second) if socket != nil { console, err := socket.ReceiveMaster() if err != nil { + cancel() return errors.Wrap(err, "failed to retrieve console master") } if e.console, err = e.parent.Platform.CopyConsole(ctx, console, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, ©WaitGroup); err != nil { + cancel() return errors.Wrap(err, "failed to start console copy") } } else if !e.stdio.IsNull() { if err := copyPipes(ctx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, ©WaitGroup); err != nil { + cancel() return errors.Wrap(err, "failed to start io pipe copy") } } copyWaitGroup.Wait() pid, err := runc.ReadPidFile(opts.PidFile) if err != nil { + cancel() return errors.Wrap(err, "failed to retrieve OCI runtime exec pid") } e.pid = pid diff --git a/components/engine/vendor/github.com/containerd/containerd/runtime/v1/linux/proc/init.go b/components/engine/vendor/github.com/containerd/containerd/runtime/v1/linux/proc/init.go index fa23b5e883..c76bcfe43d 100644 --- a/components/engine/vendor/github.com/containerd/containerd/runtime/v1/linux/proc/init.go +++ b/components/engine/vendor/github.com/containerd/containerd/runtime/v1/linux/proc/init.go @@ -168,18 +168,22 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) error { p.closers = append(p.closers, sc) } var copyWaitGroup sync.WaitGroup + ctx, cancel := context.WithTimeout(ctx, 30*time.Second) if socket != nil { console, err := socket.ReceiveMaster() if err != nil { + cancel() return errors.Wrap(err, "failed to retrieve console master") } console, err = p.Platform.CopyConsole(ctx, console, r.Stdin, r.Stdout, r.Stderr, &p.wg, ©WaitGroup) if err != nil { + cancel() return errors.Wrap(err, "failed to start console copy") } p.console = console } else if !hasNoIO(r) { if err := copyPipes(ctx, p.io, r.Stdin, r.Stdout, r.Stderr, &p.wg, ©WaitGroup); err != nil { + cancel() return errors.Wrap(err, "failed to start io pipe copy") } } @@ -187,6 +191,7 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) error { copyWaitGroup.Wait() pid, err := runc.ReadPidFile(pidFile) if err != nil { + cancel() return errors.Wrap(err, "failed to retrieve OCI runtime container pid") } p.pid = pid From f72ff31415ed90462264ca755d465fc2abb0f090 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 14 Dec 2018 11:56:23 -0500 Subject: [PATCH 2/2] Propagate context to exec delete Signed-off-by: Michael Crosby (cherry picked from commit 96e0ba1afb228b48aa6e08a90cfc665083d24ccc) Signed-off-by: Andrew Hsu Upstream-commit: b6430ba41388f0300ceea95c10738cbe1a9a7b10 Component: engine --- components/engine/libcontainerd/client_daemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/engine/libcontainerd/client_daemon.go b/components/engine/libcontainerd/client_daemon.go index cb9cb43a73..7937c96847 100644 --- a/components/engine/libcontainerd/client_daemon.go +++ b/components/engine/libcontainerd/client_daemon.go @@ -384,7 +384,7 @@ func (c *client) Exec(ctx context.Context, containerID, processID string, spec * defer close(stdinCloseSync) if err = p.Start(ctx); err != nil { - p.Delete(context.Background()) + p.Delete(ctx) ctr.deleteProcess(processID) return -1, wrapError(err) }