Merge pull request #1701 from stevvooe/backoff-v1-images
remotes/docker/schema1: back off on locked ref
This commit is contained in:
commit
7fd20edf4e
@ -9,6 +9,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math/rand"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -215,13 +216,26 @@ func (c *Converter) fetchManifest(ctx context.Context, desc ocispec.Descriptor)
|
|||||||
func (c *Converter) fetchBlob(ctx context.Context, desc ocispec.Descriptor) error {
|
func (c *Converter) fetchBlob(ctx context.Context, desc ocispec.Descriptor) error {
|
||||||
log.G(ctx).Debug("fetch blob")
|
log.G(ctx).Debug("fetch blob")
|
||||||
|
|
||||||
ref := remotes.MakeRefKey(ctx, desc)
|
var (
|
||||||
|
ref = remotes.MakeRefKey(ctx, desc)
|
||||||
calc := newBlobStateCalculator()
|
calc = newBlobStateCalculator()
|
||||||
|
retry = 16
|
||||||
|
)
|
||||||
|
|
||||||
|
tryit:
|
||||||
cw, err := c.contentStore.Writer(ctx, ref, desc.Size, desc.Digest)
|
cw, err := c.contentStore.Writer(ctx, ref, desc.Size, desc.Digest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errdefs.IsAlreadyExists(err) {
|
if errdefs.IsUnavailable(err) {
|
||||||
|
select {
|
||||||
|
case <-time.After(time.Millisecond * time.Duration(rand.Intn(retry))):
|
||||||
|
if retry < 2048 {
|
||||||
|
retry = retry << 1
|
||||||
|
}
|
||||||
|
goto tryit
|
||||||
|
case <-ctx.Done():
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else if !errdefs.IsAlreadyExists(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
@ -84,7 +85,7 @@ func fetch(ctx context.Context, ingester content.Ingester, fetcher Fetcher, desc
|
|||||||
// of writer and abort if not updated recently.
|
// of writer and abort if not updated recently.
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(time.Millisecond * time.Duration(retry)):
|
case <-time.After(time.Millisecond * time.Duration(rand.Intn(retry))):
|
||||||
if retry < 2048 {
|
if retry < 2048 {
|
||||||
retry = retry << 1
|
retry = retry << 1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user