Convert OOM Metric to Const

This converts the oom metric to be a const metric so that deleted tasks
do not fill up the metric labels.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-08-31 16:15:41 -04:00
parent 4291fb4803
commit b04e408a4b
4 changed files with 38 additions and 20 deletions

View File

@@ -251,7 +251,9 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
}
// after the task is created, add it to the monitor
if err = r.monitor.Monitor(t); err != nil {
r.tasks.Delete(ctx, t)
if _, err := r.Delete(ctx, t); err != nil {
log.G(ctx).WithError(err).Error("deleting task after failed monitor")
}
return nil, err
}
return t, nil
@@ -269,6 +271,7 @@ func (r *Runtime) Delete(ctx context.Context, c runtime.Task) (*runtime.Exit, er
if err := r.monitor.Stop(lc); err != nil {
return nil, err
}
rsp, err := lc.shim.Delete(ctx, empty)
if err != nil {
return nil, errdefs.FromGRPC(err)