Add cio.Load for loading io set

This adds a `Load` Opt for cio to load a tasks io/fifos without
attaching or starting the copy routines.

It adds the load method in `ctr` by default so that fifos or other IO
are removed from disk on delete methods inbetween command runs.  It is
not the default for all task loads for backwards compat. and a user may
want to keep io around to reuse or if log files are used.

Fixes #2421

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2018-06-26 10:17:24 -04:00
parent f15c3be348
commit fdceb13b14
4 changed files with 22 additions and 6 deletions

View File

@@ -25,6 +25,7 @@ import (
"text/tabwriter"
"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/cmd/ctr/commands/run"
"github.com/containerd/containerd/log"
@@ -162,7 +163,6 @@ var deleteCommand = cli.Command{
log.G(ctx).WithError(err).Errorf("failed to delete container %q", arg)
}
}
return exitErr
},
}
@@ -172,7 +172,7 @@ func deleteContainer(ctx context.Context, client *containerd.Client, id string,
if err != nil {
return err
}
task, err := container.Task(ctx, nil)
task, err := container.Task(ctx, cio.Load)
if err != nil {
return container.Delete(ctx, opts...)
}