Refactor task service metrics

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-09-05 11:50:56 -04:00
parent 16fcb8dc08
commit 697dcdd407
12 changed files with 965 additions and 99 deletions

View File

@@ -5,17 +5,31 @@ file {
message_type {
name: "RuncOptions"
field {
name: "criu_path"
name: "runtime"
number: 1
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "runtime"
}
field {
name: "runtime_root"
number: 2
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "runtimeRoot"
}
field {
name: "criu_path"
number: 3
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "criuPath"
}
field {
name: "systemd_cgroup"
number: 2
number: 4
label: LABEL_OPTIONAL
type: TYPE_STRING
type: TYPE_BOOL
json_name: "systemdCgroup"
}
}

View File

@@ -245,7 +245,10 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
if err != nil {
return nil, errdefs.FromGRPC(err)
}
t := newTask(id, namespace, int(cr.Pid), s)
t, err := newTask(id, namespace, int(cr.Pid), s)
if err != nil {
return nil, err
}
if err := r.tasks.Add(ctx, t); err != nil {
return nil, err
}

View File

@@ -5,6 +5,7 @@ package linux
import (
"context"
"github.com/containerd/cgroups"
"github.com/containerd/containerd/api/types/task"
"github.com/containerd/containerd/errdefs"
client "github.com/containerd/containerd/linux/shim"
@@ -18,15 +19,21 @@ type Task struct {
pid int
shim *client.Client
namespace string
cg *cgroups.Cgroup
}
func newTask(id, namespace string, pid int, shim *client.Client) *Task {
func newTask(id, namespace string, pid int, shim *client.Client) (*Task, error) {
cg, err := cgroups.Load(cgroups.V1, cgroups.PidPath(pid))
if err != nil {
return nil, err
}
return &Task{
id: id,
pid: pid,
shim: shim,
namespace: namespace,
}
cg: cg,
}, nil
}
func (t *Task) ID() string {
@@ -201,3 +208,7 @@ func (t *Task) Process(ctx context.Context, id string) (runtime.Process, error)
t: t,
}, nil
}
func (t *Task) Metrics(ctx context.Context) (interface{}, error) {
return nil, nil
}