Refactor runtime initialization
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
36e5548e76
commit
66a70e7fda
@ -268,7 +268,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errdefs.FromGRPC(err)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -410,8 +410,14 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
|||||||
}
|
}
|
||||||
continue
|
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 {
|
if err != nil {
|
||||||
log.G(ctx).WithError(err).Error("loading task type")
|
log.G(ctx).WithError(err).Error("loading task type")
|
||||||
continue
|
continue
|
||||||
@ -537,5 +543,5 @@ func (r *Runtime) getRuncOptions(ctx context.Context, id string) (*runctypes.Run
|
|||||||
|
|
||||||
return ropts, nil
|
return ropts, nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return &runcopts.RuncOptions{}, nil
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/containerd/containerd/linux/shim/client"
|
"github.com/containerd/containerd/linux/shim/client"
|
||||||
shim "github.com/containerd/containerd/linux/shim/v1"
|
shim "github.com/containerd/containerd/linux/shim/v1"
|
||||||
"github.com/containerd/containerd/runtime"
|
"github.com/containerd/containerd/runtime"
|
||||||
|
runc "github.com/containerd/go-runc"
|
||||||
"github.com/gogo/protobuf/types"
|
"github.com/gogo/protobuf/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,9 +30,10 @@ type Task struct {
|
|||||||
cg cgroups.Cgroup
|
cg cgroups.Cgroup
|
||||||
monitor runtime.TaskMonitor
|
monitor runtime.TaskMonitor
|
||||||
events *exchange.Exchange
|
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 (
|
var (
|
||||||
err error
|
err error
|
||||||
cg cgroups.Cgroup
|
cg cgroups.Cgroup
|
||||||
@ -50,6 +52,7 @@ func newTask(id, namespace string, pid int, shim *client.Client, monitor runtime
|
|||||||
cg: cg,
|
cg: cg,
|
||||||
monitor: monitor,
|
monitor: monitor,
|
||||||
events: events,
|
events: events,
|
||||||
|
runtime: runtime,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user