Skip to content

Commit cab9251

Browse files
authored
Merge pull request #56 from infosiftr/try-for-speed
Attempt to speed up deploy
2 parents 672ed1d + c70a534 commit cab9251

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

registry/push.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
var (
17-
// 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)
17+
// 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)
1818
BlobSizeWorthHEAD = int64(65535)
1919
)
2020

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

46-
if desc.Size > BlobSizeWorthHEAD {
47-
r, err := Lookup(ctx, ref, &LookupOptions{Head: true})
48-
if err != nil {
49-
return desc, fmt.Errorf("%s: failed HEAD: %w", ref, err)
50-
}
51-
// 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
52-
if r != nil {
53-
head := r.Descriptor()
54-
r.Close()
55-
if head.Digest == desc.Digest && head.Size == desc.Size {
56-
return head, nil
57-
}
46+
// try HEAD request before pushing
47+
// if it matches, then we can assume child objects exist as well
48+
r, err := Lookup(ctx, ref, &LookupOptions{Head: true})
49+
if err != nil {
50+
return desc, fmt.Errorf("%s: failed HEAD: %w", ref, err)
51+
}
52+
// 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
53+
if r != nil {
54+
head := r.Descriptor()
55+
r.Close()
56+
if head.Digest == desc.Digest && head.Size == desc.Size {
57+
return head, nil
5858
}
5959
}
6060

0 commit comments

Comments
 (0)