Handle empty blob files more appropriately
Several API tests were added to ensure correct acceptance of zero-size and empty tar files. This led to several changes in the storage backend around the guarantees of remote file reading, which backs the layer and layer upload type. In support of these changes, zero-length and empty checks have been added to the digest package. These provide a sanity check against upstream tarsum changes. The fileReader has been modified to be more robust when reading and seeking on zero-length or non-existent files. The file no longer needs to exist for the reader to be created. Seeks can now move beyond the end of the file, causing reads to issue an io.EOF. This eliminates errors during certain race conditions for reading files which should be detected by stat calls. As a part of this, a few error types were factored out and the read buffer size was increased to something more reasonable. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
097fce3bb2
commit
0270bec916
12 changed files with 218 additions and 91 deletions
|
@ -80,28 +80,10 @@ func (err ErrUnknownLayer) Error() string {
|
|||
// ErrLayerInvalidDigest returned when tarsum check fails.
|
||||
type ErrLayerInvalidDigest struct {
|
||||
Digest digest.Digest
|
||||
Reason error
|
||||
}
|
||||
|
||||
func (err ErrLayerInvalidDigest) Error() string {
|
||||
return fmt.Sprintf("invalid digest for referenced layer: %v", err.Digest)
|
||||
}
|
||||
|
||||
// ErrLayerInvalidSize returned when length check fails.
|
||||
type ErrLayerInvalidSize struct {
|
||||
Size int64
|
||||
}
|
||||
|
||||
func (err ErrLayerInvalidSize) Error() string {
|
||||
return fmt.Sprintf("invalid layer size: %d", err.Size)
|
||||
}
|
||||
|
||||
// ErrLayerUploadUnavailable signals missing upload data, either when no data
|
||||
// has been received or when the backend reports the data as missing. This is
|
||||
// different from ErrLayerUploadUnknown.
|
||||
type ErrLayerUploadUnavailable struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
func (err ErrLayerUploadUnavailable) Error() string {
|
||||
return fmt.Sprintf("layer upload unavialable: %v", err)
|
||||
return fmt.Sprintf("invalid digest for referenced layer: %v, %v",
|
||||
err.Digest, err.Reason)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue