Change for new containerd.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
e5f6cbce51
commit
aa83a7a0aa
@ -20,13 +20,13 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/containerd/cmd/ctr/command"
|
||||
ctrapp "github.com/containerd/containerd/cmd/ctr/app"
|
||||
|
||||
cricli "github.com/containerd/cri/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := command.App()
|
||||
app := ctrapp.New()
|
||||
app.Commands = append(app.Commands, cricli.Command)
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ctr: %s\n", err)
|
||||
|
@ -30,6 +30,7 @@ import (
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/leases"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/image-spec/specs-go"
|
||||
@ -81,8 +82,15 @@ func Import(ctx context.Context, client *containerd.Client, reader io.Reader) (_
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TODO(random-liu): Fix this after containerd client is fixed (containerd/containerd#2193)
|
||||
defer done() // nolint: errcheck
|
||||
defer func() {
|
||||
deferCtx, deferCancel := ctrdutil.DeferContext()
|
||||
defer deferCancel()
|
||||
if err := done(deferCtx); err != nil {
|
||||
// Get lease id from context still works after context is done.
|
||||
leaseID, _ := leases.Lease(ctx)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to release lease %q", leaseID)
|
||||
}
|
||||
}()
|
||||
|
||||
cs := client.ContentStore()
|
||||
is := client.ImageService()
|
||||
|
Loading…
Reference in New Issue
Block a user