X Tutup
Skip to content

Commit 66a70e7

Browse files
committed
Refactor runtime initialization
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
1 parent 36e5548 commit 66a70e7

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

linux/runtime.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
268268
if err != nil {
269269
return nil, errdefs.FromGRPC(err)
270270
}
271-
t, err := newTask(id, namespace, int(cr.Pid), s, r.monitor, r.events)
271+
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))
272272
if err != nil {
273273
return nil, err
274274
}
@@ -410,8 +410,14 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
410410
}
411411
continue
412412
}
413+
ropts, err := r.getRuncOptions(ctx, id)
414+
if err != nil {
415+
log.G(ctx).WithError(err).WithField("id", id).
416+
Error("get runtime options")
417+
continue
418+
}
413419

414-
t, err := newTask(id, ns, pid, s, r.monitor, r.events)
420+
t, err := newTask(id, ns, pid, s, r.monitor, r.events, proc.NewRunc(ropts.RuntimeRoot, bundle.path, ns, ropts.Runtime, ropts.CriuPath, ropts.SystemdCgroup))
415421
if err != nil {
416422
log.G(ctx).WithError(err).Error("loading task type")
417423
continue
@@ -537,5 +543,5 @@ func (r *Runtime) getRuncOptions(ctx context.Context, id string) (*runctypes.Run
537543

538544
return ropts, nil
539545
}
540-
return nil, nil
546+
return &runcopts.RuncOptions{}, nil
541547
}

linux/task.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/containerd/containerd/linux/shim/client"
1818
shim "github.com/containerd/containerd/linux/shim/v1"
1919
"github.com/containerd/containerd/runtime"
20+
runc "github.com/containerd/go-runc"
2021
"github.com/gogo/protobuf/types"
2122
)
2223

@@ -29,9 +30,10 @@ type Task struct {
2930
cg cgroups.Cgroup
3031
monitor runtime.TaskMonitor
3132
events *exchange.Exchange
33+
runtime *runc.Runc
3234
}
3335

34-
func newTask(id, namespace string, pid int, shim *client.Client, monitor runtime.TaskMonitor, events *exchange.Exchange) (*Task, error) {
36+
func newTask(id, namespace string, pid int, shim *client.Client, monitor runtime.TaskMonitor, events *exchange.Exchange, runtime *runc.Runc) (*Task, error) {
3537
var (
3638
err error
3739
cg cgroups.Cgroup
@@ -50,6 +52,7 @@ func newTask(id, namespace string, pid int, shim *client.Client, monitor runtime
5052
cg: cg,
5153
monitor: monitor,
5254
events: events,
55+
runtime: runtime,
5356
}, nil
5457
}
5558

0 commit comments

Comments
 (0)
X Tutup