Support task creation options passed by ContainerD 1.2.4 (#20)

When ContainerD v1.2.4 creates a task, it may pass a *runctypes.CreateOptions in the request options field. This currently causes the gvisor-containerd-shim to reject the request.

This PR allows the shim to handle requests with creation options set, and also slightly improves the error message so future failures of this kind are easier to localize to the shim.

Fixes #19
This commit is contained in:
jmillikin-stripe
2019-03-29 14:00:49 +09:00
committed by Ian Lewis
parent b7015c1a46
commit 5ff5bb636d
+5 -1
View File
@@ -240,6 +240,10 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *
}
var path string
switch o := v.(type) {
case *runctypes.CreateOptions: // containerd 1.2.x
opts.IoUid = o.IoUid
opts.IoGid = o.IoGid
opts.ShimCgroup = o.ShimCgroup
case *runctypes.RuncOptions: // containerd 1.2.x
root := proc.RunscRoot
if o.RuntimeRoot != "" {
@@ -262,7 +266,7 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *
}
path = o.ConfigPath
default:
return nil, errors.Errorf("unsupported option type")
return nil, errors.Errorf("unsupported option type %q", r.Options.TypeUrl)
}
if path != "" {
if _, err = toml.DecodeFile(path, &opts); err != nil {