Merge pull request #450 from Random-Liu/update-containerd

Update containerd to fix fd leakage.
This commit is contained in:
Lantao Liu 2017-11-30 17:04:46 -08:00 committed by GitHub
commit 0a954e7a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 9 deletions

View File

@ -1,5 +1,5 @@
RUNC_VERSION=74a17296470088de3805e138d3d87c62e613dfc4 RUNC_VERSION=74a17296470088de3805e138d3d87c62e613dfc4
CNI_VERSION=v0.6.0 CNI_VERSION=v0.6.0
CONTAINERD_VERSION=8114d2f2e255b9bd06c6d4377eb235ca809fc895 CONTAINERD_VERSION=4bcd272c14255fd625f1cdfbdaa7623b668caa70
CRITOOL_VERSION=4cd2b047a26a2ef01bbd02ee55f7d70d8825ebb5 CRITOOL_VERSION=4cd2b047a26a2ef01bbd02ee55f7d70d8825ebb5
KUBERNETES_VERSION=164317879bcd810b97e5ebf1c8df041770f2ff1b KUBERNETES_VERSION=164317879bcd810b97e5ebf1c8df041770f2ff1b

View File

@ -2,7 +2,7 @@ github.com/blang/semver v3.1.0
github.com/boltdb/bolt e9cf4fae01b5a8ff89d0ec6b32f0d9c9f79aefdd github.com/boltdb/bolt e9cf4fae01b5a8ff89d0ec6b32f0d9c9f79aefdd
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895 github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895
github.com/containerd/cgroups 29da22c6171a4316169f9205ab6c49f59b5b852f github.com/containerd/cgroups 29da22c6171a4316169f9205ab6c49f59b5b852f
github.com/containerd/containerd 8114d2f2e255b9bd06c6d4377eb235ca809fc895 github.com/containerd/containerd 4bcd272c14255fd625f1cdfbdaa7623b668caa70
github.com/containerd/continuity cf279e6ac893682272b4479d4c67fd3abf878b4e github.com/containerd/continuity cf279e6ac893682272b4479d4c67fd3abf878b4e
github.com/containerd/fifo fbfb6a11ec671efbe94ad1c12c2e98773f19e1e6 github.com/containerd/fifo fbfb6a11ec671efbe94ad1c12c2e98773f19e1e6
github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788 github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788

View File

@ -162,11 +162,17 @@ func (c *container) Image(ctx context.Context) (Image, error) {
}, nil }, nil
} }
func (c *container) NewTask(ctx context.Context, ioCreate cio.Creation, opts ...NewTaskOpts) (Task, error) { func (c *container) NewTask(ctx context.Context, ioCreate cio.Creation, opts ...NewTaskOpts) (_ Task, err error) {
i, err := ioCreate(c.id) i, err := ioCreate(c.id)
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() {
if err != nil && i != nil {
i.Cancel()
i.Close()
}
}()
cfg := i.Config() cfg := i.Config()
request := &tasks.CreateTaskRequest{ request := &tasks.CreateTaskRequest{
ContainerID: c.id, ContainerID: c.id,

View File

@ -101,7 +101,7 @@ func WithImageConfig(image Image) SpecOpts {
parts := strings.Split(config.User, ":") parts := strings.Split(config.User, ":")
switch len(parts) { switch len(parts) {
case 1: case 1:
v, err := strconv.ParseUint(parts[0], 0, 10) v, err := strconv.Atoi(parts[0])
if err != nil { if err != nil {
// if we cannot parse as a uint they try to see if it is a username // if we cannot parse as a uint they try to see if it is a username
if err := WithUsername(config.User)(ctx, client, c, s); err != nil { if err := WithUsername(config.User)(ctx, client, c, s); err != nil {
@ -113,13 +113,13 @@ func WithImageConfig(image Image) SpecOpts {
return err return err
} }
case 2: case 2:
v, err := strconv.ParseUint(parts[0], 0, 10) v, err := strconv.Atoi(parts[0])
if err != nil { if err != nil {
return err return errors.Wrapf(err, "parse uid %s", parts[0])
} }
uid := uint32(v) uid := uint32(v)
if v, err = strconv.ParseUint(parts[1], 0, 10); err != nil { if v, err = strconv.Atoi(parts[1]); err != nil {
return err return errors.Wrapf(err, "parse gid %s", parts[1])
} }
gid := uint32(v) gid := uint32(v)
s.Process.User.UID, s.Process.User.GID = uid, gid s.Process.User.UID, s.Process.User.GID = uid, gid

View File

@ -277,7 +277,7 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat
return &ExitStatus{code: r.ExitStatus, exitedAt: r.ExitedAt}, nil return &ExitStatus{code: r.ExitStatus, exitedAt: r.ExitedAt}, nil
} }
func (t *task) Exec(ctx context.Context, id string, spec *specs.Process, ioCreate cio.Creation) (Process, error) { func (t *task) Exec(ctx context.Context, id string, spec *specs.Process, ioCreate cio.Creation) (_ Process, err error) {
if id == "" { if id == "" {
return nil, errors.Wrapf(errdefs.ErrInvalidArgument, "exec id must not be empty") return nil, errors.Wrapf(errdefs.ErrInvalidArgument, "exec id must not be empty")
} }
@ -285,6 +285,12 @@ func (t *task) Exec(ctx context.Context, id string, spec *specs.Process, ioCreat
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() {
if err != nil && i != nil {
i.Cancel()
i.Close()
}
}()
any, err := typeurl.MarshalAny(spec) any, err := typeurl.MarshalAny(spec)
if err != nil { if err != nil {
return nil, err return nil, err