opencontainers / distribution-spec

OCI Distribution Specification
https://opencontainers.org
Apache License 2.0
811 stars 202 forks source link

How should an upload be resumed? #353

Closed lgalfaso closed 1 year ago

lgalfaso commented 1 year ago

The spec talks about Resumable Push but it is not clear how this should be performed. Docker API v2 spec defines that when sending a chunk in a session, if the range does not match, then the response should be of the following form

416 Requested Range Not Satisfiable
Location: /v2/<name>/blobs/uploads/<uuid>
Range: 0-<last valid range>
Content-Length: 0
Docker-Upload-UUID: <uuid>

the key here being that there is Range: 0-<last valid range> that would tell the client about the last position written.

sudo-bmitch commented 1 year ago

Under the Push definition, there's a PATCH description that includes the range. I don't think that's valid to resume a partial PUT, you'd need to do it from the first request.

lgalfaso commented 1 year ago

The Resumable Push section reads (emphasis are mine)

Company X's build servers lose connectivity to a distribution endpoint before completing an artifact layer transfer. After connectivity returns, the build server attempts to re-upload the artifact. The registry notifies the build server that the upload has already been partially attempted. The build server responds by only sending the remaining data to complete the artifact file.

Following the same naming conventions, if the build server wants to know what is the last byte that was uploaded in order to resume the upload from this point. How it is suppose to do so? Returning Range: 0-<last valid range> is a way to inform this specific information.