Skip to content

Commit 0515f9d

Browse files
corybthaJeztah
authored andcommitted
Fix missing Body.Close() calls on push to docker remote
Discovered this while using HTTP tracing via OpenTelemetry inside of buildkitd, where the trace spans were not being reported for the registry PUT http requests. The spans are only reported on the Close for the Body, after adding these Close calls, the spans are reported as expected. Signed-off-by: coryb <[email protected]> (cherry picked from commit 894b6ae) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9be04c2 commit 0515f9d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

remotes/docker/pusher.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
190190
return nil, err
191191
}
192192
}
193+
defer resp.Body.Close()
193194

194195
switch resp.StatusCode {
195196
case http.StatusOK, http.StatusAccepted, http.StatusNoContent:
@@ -382,6 +383,7 @@ func (pw *pushWriter) Commit(ctx context.Context, size int64, expected digest.Di
382383
if resp.err != nil {
383384
return resp.err
384385
}
386+
defer resp.Response.Body.Close()
385387

386388
// 201 is specified return status, some registries return
387389
// 200, 202 or 204.

0 commit comments

Comments
 (0)