Skip to content

Commit

Permalink
Delete task on dead shim
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
  • Loading branch information
crosbymichael committed Feb 6, 2018
1 parent 04b5f3f commit d1d3fd0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions linux/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
"id": id,
"namespace": namespace,
}).Warn("cleaning up after killed shim")
err = r.cleanupAfterDeadShim(context.Background(), bundle, namespace, id, lc.pid)
if err == nil {
r.tasks.Delete(ctx, lc)
} else {
if err = r.cleanupAfterDeadShim(context.Background(), bundle, namespace, id, lc.pid); err != nil {
log.G(ctx).WithError(err).WithFields(logrus.Fields{
"id": id,
"namespace": namespace,
Expand Down Expand Up @@ -313,7 +310,7 @@ func (r *Runtime) Delete(ctx context.Context, c runtime.Task) (*runtime.Exit, er
}
return nil, errdefs.FromGRPC(err)
}
r.tasks.Delete(ctx, lc)
r.tasks.Delete(ctx, lc.id)
if err := lc.shim.KillShim(ctx); err != nil {
log.G(ctx).WithError(err).Error("failed to kill shim")
}
Expand Down Expand Up @@ -443,6 +440,7 @@ func (r *Runtime) cleanupAfterDeadShim(ctx context.Context, bundle *bundle, ns,
ExitedAt: exitedAt,
})

r.tasks.Delete(ctx, id)
if err := bundle.Delete(); err != nil {
log.G(ctx).WithError(err).Error("delete bundle")
}
Expand All @@ -458,12 +456,10 @@ func (r *Runtime) cleanupAfterDeadShim(ctx context.Context, bundle *bundle, ns,
}

func (r *Runtime) terminate(ctx context.Context, bundle *bundle, ns, id string) error {
ctx = namespaces.WithNamespace(ctx, ns)
rt, err := r.getRuntime(ctx, ns, id)
if err != nil {
return err
}

if err := rt.Delete(ctx, id, &runc.DeleteOpts{
Force: true,
}); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions runtime/task_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (l *TaskList) AddWithNamespace(namespace string, t Task) error {
}

// Delete a task
func (l *TaskList) Delete(ctx context.Context, t Task) {
func (l *TaskList) Delete(ctx context.Context, id string) {
l.mu.Lock()
defer l.mu.Unlock()
namespace, err := namespaces.NamespaceRequired(ctx)
Expand All @@ -101,6 +101,6 @@ func (l *TaskList) Delete(ctx context.Context, t Task) {
}
tasks, ok := l.tasks[namespace]
if ok {
delete(tasks, t.ID())
delete(tasks, id)
}
}
2 changes: 1 addition & 1 deletion windows/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (r *windowsRuntime) Delete(ctx context.Context, t runtime.Task) (*runtime.E
}

wt.cleanup()
r.tasks.Delete(ctx, t)
r.tasks.Delete(ctx, t.ID())

r.publisher.Publish(ctx,
runtime.TaskDeleteEventTopic,
Expand Down

0 comments on commit d1d3fd0

Please sign in to comment.