mirror of
https://github.com/distribution/distribution.git
synced 2025-08-19 23:38:13 +00:00
s3: Handle QuotaExceeded errors
Add a new storagedriver error to be used when quotas are exceeded, and return it from the S3 driver. Signed-off-by: Adam Wolfe Gordon <awg@digitalocean.com>
This commit is contained in:
parent
f2331f9d03
commit
d192a974fb
@ -80,6 +80,9 @@ func (base *Base) setDriverName(e error) error {
|
||||
case storagedriver.InvalidOffsetError:
|
||||
actual.DriverName = base.StorageDriver.Name()
|
||||
return actual
|
||||
case storagedriver.QuotaExceededError:
|
||||
actual.DriverName = base.StorageDriver.Name()
|
||||
return actual
|
||||
default:
|
||||
storageError := storagedriver.Error{
|
||||
DriverName: base.StorageDriver.Name(),
|
||||
|
@ -1188,8 +1188,13 @@ func (d *Driver) S3BucketKey(path string) string {
|
||||
}
|
||||
|
||||
func parseError(path string, err error) error {
|
||||
if s3Err, ok := err.(awserr.Error); ok && s3Err.Code() == "NoSuchKey" {
|
||||
if s3Err, ok := err.(awserr.Error); ok {
|
||||
switch s3Err.Code() {
|
||||
case "NoSuchKey":
|
||||
return storagedriver.PathNotFoundError{Path: path}
|
||||
case "QuotaExceeded":
|
||||
return storagedriver.QuotaExceededError{}
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
|
@ -159,6 +159,16 @@ func (err InvalidOffsetError) Error() string {
|
||||
return fmt.Sprintf("%s: invalid offset: %d for path: %s", err.DriverName, err.Offset, err.Path)
|
||||
}
|
||||
|
||||
// QuotaExceededError is returned when a storage quota is exceeded during a
|
||||
// write.
|
||||
type QuotaExceededError struct {
|
||||
DriverName string
|
||||
}
|
||||
|
||||
func (err QuotaExceededError) Error() string {
|
||||
return fmt.Sprintf("%s: quota exceeded", err.DriverName)
|
||||
}
|
||||
|
||||
// Error is a catch-all error type which captures an error string and
|
||||
// the driver type on which it occurred.
|
||||
type Error struct {
|
||||
|
Loading…
Reference in New Issue
Block a user