Fix race in ctr pull
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
e017143dde
commit
f701b3b960
@ -61,19 +61,19 @@ Most of this is experimental and there are few leaps to make this work.`,
|
||||
var (
|
||||
ref = clicontext.Args().First()
|
||||
)
|
||||
_, err := Fetch(ref, clicontext)
|
||||
client, ctx, cancel, err := commands.NewClient(clicontext)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
_, err = Fetch(ctx, client, ref, clicontext)
|
||||
return err
|
||||
},
|
||||
}
|
||||
|
||||
// Fetch loads all resources into the content store and returns the image
|
||||
func Fetch(ref string, cliContext *cli.Context) (containerd.Image, error) {
|
||||
client, ctx, cancel, err := commands.NewClient(cliContext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
func Fetch(ctx context.Context, client *containerd.Client, ref string, cliContext *cli.Context) (containerd.Image, error) {
|
||||
resolver, err := commands.GetResolver(ctx, cliContext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -57,10 +57,20 @@ command. As part of this process, we do the following:
|
||||
if ref == "" {
|
||||
return fmt.Errorf("please provide an image reference to pull")
|
||||
}
|
||||
ctx, cancel := commands.AppContext(context)
|
||||
|
||||
client, ctx, cancel, err := commands.NewClient(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
img, err := content.Fetch(ref, context)
|
||||
ctx, done, err := client.WithLease(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer done(ctx)
|
||||
|
||||
img, err := content.Fetch(ctx, client, ref, context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user