Skip to content

Commit 4473698

Browse files
committed
Revert "Attempt to speed up deploy"
This reverts commit c70a534. (After fixing the implementation bug, this made things worse, not better 😭)
1 parent e0a32c0 commit 4473698

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

registry/push.go

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

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

@@ -43,23 +43,25 @@ 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-
// try HEAD request before pushing
47-
// if it matches, then we can assume child objects exist as well
48-
headRef := ref
49-
if headRef.Tag != "" {
50-
// if this function is called with *both* tag *and* digest, the code below works correctly and pushes by tag and then validates by digest, but this lookup specifically will prefer the digest instead and skip when it shouldn't
51-
headRef.Digest = ""
52-
}
53-
r, err := Lookup(ctx, headRef, &LookupOptions{Head: true})
54-
if err != nil {
55-
return desc, fmt.Errorf("%s: failed HEAD: %w", ref, err)
56-
}
57-
// 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
58-
if r != nil {
59-
head := r.Descriptor()
60-
r.Close()
61-
if head.Digest == desc.Digest && head.Size == desc.Size {
62-
return head, nil
46+
if desc.Size > BlobSizeWorthHEAD {
47+
// try HEAD request before pushing
48+
// if it matches, then we can assume child objects exist as well
49+
headRef := ref
50+
if headRef.Tag != "" {
51+
// if this function is called with *both* tag *and* digest, the code below works correctly and pushes by tag and then validates by digest, but this lookup specifically will prefer the digest instead and skip when it shouldn't
52+
headRef.Digest = ""
53+
}
54+
r, err := Lookup(ctx, headRef, &LookupOptions{Head: true})
55+
if err != nil {
56+
return desc, fmt.Errorf("%s: failed HEAD: %w", ref, err)
57+
}
58+
// 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
59+
if r != nil {
60+
head := r.Descriptor()
61+
r.Close()
62+
if head.Digest == desc.Digest && head.Size == desc.Size {
63+
return head, nil
64+
}
6365
}
6466
}
6567

0 commit comments

Comments
 (0)