Pull: create image record after blobs download

When pull image with unpack option, the fetch action will defer blobs
download until unpack. If create image record in ImageService before
blobs download, the following requests to use image will fail because
there is still missing blobs download.

In order to fix concurrent issue, need to create image record after
blobs download.

Fix: #3937

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu
2020-01-20 14:11:53 +08:00
parent 592a617f3d
commit 75af17946d
2 changed files with 31 additions and 5 deletions

View File

@@ -390,7 +390,11 @@ func (c *Client) Fetch(ctx context.Context, ref string, opts ...RemoteOpt) (imag
}
defer done(ctx)
return c.fetch(ctx, fetchCtx, ref, 0)
img, err := c.fetch(ctx, fetchCtx, ref, 0)
if err != nil {
return images.Image{}, err
}
return c.createNewImage(ctx, img)
}
// Push uploads the provided content to a remote resource