Skip to content

Commit

Permalink
Merge pull request #56 from infosiftr/try-for-speed
Browse files Browse the repository at this point in the history
Attempt to speed up deploy
  • Loading branch information
tianon authored Jun 25, 2024
2 parents 672ed1d + c70a534 commit cab9251
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions registry/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

var (
// if a manifest or blob is more than this many bytes, we'll do a pre-flight HEAD request to verify whether we need to even bother pushing it before we do so (65535 is the theoretical maximum size of a single TCP packet, although MTU means it's usually closer to 1448 bytes, but this seemed like a sane place to draw a line to where a second request that might fail is worth our time)
// if a blob is more than this many bytes, we'll do a pre-flight HEAD request to verify whether we need to even bother pushing it before we do so (65535 is the theoretical maximum size of a single TCP packet, although MTU means it's usually closer to 1448 bytes, but this seemed like a sane place to draw a line to where a second request that might fail is worth our time)
BlobSizeWorthHEAD = int64(65535)
)

Expand Down Expand Up @@ -43,18 +43,18 @@ func EnsureManifest(ctx context.Context, ref Reference, manifest json.RawMessage
return desc, fmt.Errorf("%s: failed getting client: %w", ref, err)
}

if desc.Size > BlobSizeWorthHEAD {
r, err := Lookup(ctx, ref, &LookupOptions{Head: true})
if err != nil {
return desc, fmt.Errorf("%s: failed HEAD: %w", ref, err)
}
// TODO if we had some kind of progress interface, this would be a great place for some kind of debug log of head's contents
if r != nil {
head := r.Descriptor()
r.Close()
if head.Digest == desc.Digest && head.Size == desc.Size {
return head, nil
}
// try HEAD request before pushing
// if it matches, then we can assume child objects exist as well
r, err := Lookup(ctx, ref, &LookupOptions{Head: true})
if err != nil {
return desc, fmt.Errorf("%s: failed HEAD: %w", ref, err)
}
// TODO if we had some kind of progress interface, this would be a great place for some kind of debug log of head's contents
if r != nil {
head := r.Descriptor()
r.Close()
if head.Digest == desc.Digest && head.Size == desc.Size {
return head, nil
}
}

Expand Down

0 comments on commit cab9251

Please sign in to comment.