diff --git a/linux/runtime.go b/linux/runtime.go index e5b474827..95f9242e0 100644 --- a/linux/runtime.go +++ b/linux/runtime.go @@ -268,7 +268,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts if err != nil { return nil, errdefs.FromGRPC(err) } - t, err := newTask(id, namespace, int(cr.Pid), s, r.monitor, r.events) + t, err := newTask(id, namespace, int(cr.Pid), s, r.monitor, r.events, proc.NewRunc(ropts.RuntimeRoot, sopts.Bundle, namespace, rt, ropts.CriuPath, ropts.SystemdCgroup)) if err != nil { return nil, err } @@ -410,8 +410,14 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) { } continue } + ropts, err := r.getRuncOptions(ctx, id) + if err != nil { + log.G(ctx).WithError(err).WithField("id", id). + Error("get runtime options") + continue + } - t, err := newTask(id, ns, pid, s, r.monitor, r.events) + t, err := newTask(id, ns, pid, s, r.monitor, r.events, proc.NewRunc(ropts.RuntimeRoot, bundle.path, ns, ropts.Runtime, ropts.CriuPath, ropts.SystemdCgroup)) if err != nil { log.G(ctx).WithError(err).Error("loading task type") continue @@ -537,5 +543,5 @@ func (r *Runtime) getRuncOptions(ctx context.Context, id string) (*runctypes.Run return ropts, nil } - return nil, nil + return &runcopts.RuncOptions{}, nil } diff --git a/linux/task.go b/linux/task.go index 11b5032d3..d708cdb84 100644 --- a/linux/task.go +++ b/linux/task.go @@ -17,6 +17,7 @@ import ( "github.com/containerd/containerd/linux/shim/client" shim "github.com/containerd/containerd/linux/shim/v1" "github.com/containerd/containerd/runtime" + runc "github.com/containerd/go-runc" "github.com/gogo/protobuf/types" ) @@ -29,9 +30,10 @@ type Task struct { cg cgroups.Cgroup monitor runtime.TaskMonitor events *exchange.Exchange + runtime *runc.Runc } -func newTask(id, namespace string, pid int, shim *client.Client, monitor runtime.TaskMonitor, events *exchange.Exchange) (*Task, error) { +func newTask(id, namespace string, pid int, shim *client.Client, monitor runtime.TaskMonitor, events *exchange.Exchange, runtime *runc.Runc) (*Task, error) { var ( err error cg cgroups.Cgroup @@ -50,6 +52,7 @@ func newTask(id, namespace string, pid int, shim *client.Client, monitor runtime cg: cg, monitor: monitor, events: events, + runtime: runtime, }, nil }