forked from TrueCloudLab/distribution
Report layer upload as unavialable when data missing
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
c080c40030
commit
f926a93778
2 changed files with 27 additions and 1 deletions
|
@ -94,3 +94,14 @@ type ErrLayerInvalidSize struct {
|
||||||
func (err ErrLayerInvalidSize) Error() string {
|
func (err ErrLayerInvalidSize) Error() string {
|
||||||
return fmt.Sprintf("invalid layer size: %d", err.Size)
|
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)
|
||||||
|
}
|
||||||
|
|
|
@ -102,8 +102,23 @@ func (luc *layerUploadController) validateLayer(dgst digest.Digest) (digest.Dige
|
||||||
// Read the file from the backend driver and validate it.
|
// Read the file from the backend driver and validate it.
|
||||||
fr, err := newFileReader(luc.fileWriter.driver, luc.path)
|
fr, err := newFileReader(luc.fileWriter.driver, luc.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
switch err := err.(type) {
|
||||||
|
case storagedriver.PathNotFoundError:
|
||||||
|
// NOTE(stevvooe): Path not found can mean several things by we
|
||||||
|
// should report the upload is not available. This can happen if
|
||||||
|
// the following happens:
|
||||||
|
//
|
||||||
|
// 1. If not data was received for the upload instance.
|
||||||
|
// 2. Backend storage driver has not convereged after receiving latest data.
|
||||||
|
//
|
||||||
|
// This *does not* mean that the upload does not exist, since we
|
||||||
|
// can't even get a LayerUpload object without having the
|
||||||
|
// directory exist.
|
||||||
|
return "", ErrLayerUploadUnavailable{Err: err}
|
||||||
|
default:
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tr := io.TeeReader(fr, digestVerifier)
|
tr := io.TeeReader(fr, digestVerifier)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue