Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Change for new containerd.
Browse files Browse the repository at this point in the history
Signed-off-by: Lantao Liu <[email protected]>
  • Loading branch information
Random-Liu committed Mar 23, 2018
1 parent e5f6cbc commit aa83a7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/ctr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions pkg/containerd/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit aa83a7a

Please sign in to comment.