Retry image creation after update not found

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2018-05-04 14:31:27 -07:00
parent 28caf9027e
commit 2bc9f49ffd

View File

@@ -345,6 +345,7 @@ func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpt) (Image
}
is := c.ImageService()
for {
if created, err := is.Create(ctx, imgrec); err != nil {
if !errdefs.IsAlreadyExists(err) {
return nil, err
@@ -352,6 +353,10 @@ func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpt) (Image
updated, err := is.Update(ctx, imgrec)
if err != nil {
// if image was removed, try create again
if errdefs.IsNotFound(err) {
continue
}
return nil, err
}
@@ -359,6 +364,8 @@ func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpt) (Image
} else {
imgrec = created
}
break
}
img := &image{
client: c,