diff --git a/vendor.conf b/vendor.conf index 4413d4bcd..7c052d163 100644 --- a/vendor.conf +++ b/vendor.conf @@ -44,7 +44,7 @@ github.com/gotestyourself/gotestyourself 44dbf532bbf5767611f6f2a61bded572e337010 github.com/google/go-cmp v0.1.0 # cri dependencies -github.com/containerd/cri 0d01163f9cbe4f353ca1b844230eeab37cd04f35 https://github.com/ehazlett/cri +github.com/containerd/cri b68fb075d49aa1c2885f45f2467142666c244f4a github.com/containerd/go-cni f2d7272f12d045b16ed924f50e91f9f9cecc55a7 github.com/blang/semver v3.1.0 github.com/containernetworking/cni v0.6.0 diff --git a/vendor/github.com/containerd/cri/pkg/containerd/resolver/fetcher.go b/vendor/github.com/containerd/cri/pkg/containerd/resolver/fetcher.go index a6aa48431..4e01c3c4b 100644 --- a/vendor/github.com/containerd/cri/pkg/containerd/resolver/fetcher.go +++ b/vendor/github.com/containerd/cri/pkg/containerd/resolver/fetcher.go @@ -24,6 +24,7 @@ import ( "context" "fmt" "io" + "io/ioutil" "net/http" "path" "strings" @@ -92,8 +93,9 @@ func (r dockerFetcher) open(ctx context.Context, u, mediatype string, offset int req.Header.Set("Accept", strings.Join([]string{mediatype, `*`}, ", ")) if offset > 0 { - // TODO(stevvooe): Only set this header in response to the - // "Accept-Ranges: bytes" header. + // Note: "Accept-Ranges: bytes" cannot be trusted as some endpoints + // will return the header without supporting the range. The content + // range must always be checked. req.Header.Set("Range", fmt.Sprintf("bytes=%d-", offset)) } @@ -114,6 +116,30 @@ func (r dockerFetcher) open(ctx context.Context, u, mediatype string, offset int } return nil, errors.Errorf("unexpected status code %v: %v", u, resp.Status) } + if offset > 0 { + cr := resp.Header.Get("content-range") + if cr != "" { + if !strings.HasPrefix(cr, fmt.Sprintf("bytes %d-", offset)) { + return nil, errors.Errorf("unhandled content range in response: %v", cr) + + } + } else { + // TODO: Should any cases where use of content range + // without the proper header be considerd? + // 206 responses? + + // Discard up to offset + // Could use buffer pool here but this case should be rare + n, err := io.Copy(ioutil.Discard, io.LimitReader(resp.Body, offset)) + if err != nil { + return nil, errors.Wrap(err, "failed to discard to offset") + } + if n != offset { + return nil, errors.Errorf("unable to discard to offset") + } + + } + } return resp.Body, nil } diff --git a/vendor/github.com/containerd/cri/pkg/server/image_pull.go b/vendor/github.com/containerd/cri/pkg/server/image_pull.go index 4db105e06..67acddf0f 100644 --- a/vendor/github.com/containerd/cri/pkg/server/image_pull.go +++ b/vendor/github.com/containerd/cri/pkg/server/image_pull.go @@ -199,7 +199,7 @@ func (c *criService) createImageReference(ctx context.Context, name string, desc if err == nil { return nil } - if err != nil && !errdefs.IsAlreadyExists(err) { + if !errdefs.IsAlreadyExists(err) { return err } _, err = c.client.ImageService().Update(ctx, img, "target") diff --git a/vendor/github.com/containerd/cri/vendor.conf b/vendor/github.com/containerd/cri/vendor.conf index 73742b1c7..a485d715a 100644 --- a/vendor/github.com/containerd/cri/vendor.conf +++ b/vendor/github.com/containerd/cri/vendor.conf @@ -4,7 +4,7 @@ github.com/boltdb/bolt e9cf4fae01b5a8ff89d0ec6b32f0d9c9f79aefdd github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895 github.com/containerd/cgroups fe281dd265766145e943a034aa41086474ea6130 github.com/containerd/console cb7008ab3d8359b78c5f464cb7cf160107ad5925 -github.com/containerd/containerd 62da044848bffac9b68221a69f5bb4aed65fc3ef https://github.com/ehazlett/containerd +github.com/containerd/containerd 1e8b09cfc6825f7e6349884b5f76e86c1f04a5d4 github.com/containerd/continuity 2d3749b4da569ac97ca63dccba5eee4f5ee2beab github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c github.com/containerd/go-cni f2d7272f12d045b16ed924f50e91f9f9cecc55a7