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"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/containerd/containerd/cmd/ctr/command"
|
ctrapp "github.com/containerd/containerd/cmd/ctr/app"
|
||||||
|
|
||||||
cricli "github.com/containerd/cri/cli"
|
cricli "github.com/containerd/cri/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := command.App()
|
app := ctrapp.New()
|
||||||
app.Commands = append(app.Commands, cricli.Command)
|
app.Commands = append(app.Commands, cricli.Command)
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "ctr: %s\n", err)
|
fmt.Fprintf(os.Stderr, "ctr: %s\n", err)
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/images"
|
"github.com/containerd/containerd/images"
|
||||||
|
"github.com/containerd/containerd/leases"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/opencontainers/image-spec/specs-go"
|
"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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// TODO(random-liu): Fix this after containerd client is fixed (containerd/containerd#2193)
|
defer func() {
|
||||||
defer done() // nolint: errcheck
|
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()
|
cs := client.ContentStore()
|
||||||
is := client.ImageService()
|
is := client.ImageService()
|
||||||
|
Loading…
Reference in New Issue
Block a user