fix: do not return an error for successfully deleted dangling objects (#10938)

dangling objects when removed `mc admin heal -r` or crawler
auto heal would incorrectly return error - this can interfere
with usage calculation as the entry size for this would be
returned as `0`, instead upon success use the resultant
object size to calculate the final size for the object
and avoid reporting this in the log messages

Also do not set ObjectSize in healResultItem to be '-1'
this has an effect on crawler metrics calculating 1 byte
less for objects which seem to be missing their `xl.meta`
This commit is contained in:
Harshavardhana
2020-11-23 09:12:17 -08:00
committed by GitHub
parent 734d07a532
commit 519c0077a9
6 changed files with 109 additions and 102 deletions

View File

@@ -130,9 +130,27 @@ func toObjectErr(err error, params ...string) error {
}
}
case errErasureReadQuorum:
err = InsufficientReadQuorum{}
if len(params) == 1 {
err = InsufficientReadQuorum{
Bucket: params[0],
}
} else if len(params) >= 2 {
err = InsufficientReadQuorum{
Bucket: params[0],
Object: params[1],
}
}
case errErasureWriteQuorum:
err = InsufficientWriteQuorum{}
if len(params) == 1 {
err = InsufficientWriteQuorum{
Bucket: params[0],
}
} else if len(params) >= 2 {
err = InsufficientWriteQuorum{
Bucket: params[0],
Object: params[1],
}
}
case io.ErrUnexpectedEOF, io.ErrShortWrite:
err = IncompleteBody{}
case context.Canceled, context.DeadlineExceeded:
@@ -163,10 +181,10 @@ func (e SlowDown) Error() string {
}
// InsufficientReadQuorum storage cannot satisfy quorum for read operation.
type InsufficientReadQuorum struct{}
type InsufficientReadQuorum GenericError
func (e InsufficientReadQuorum) Error() string {
return "Storage resources are insufficient for the read operation."
return "Storage resources are insufficient for the read operation " + e.Bucket + "/" + e.Object
}
// Unwrap the error.
@@ -175,10 +193,10 @@ func (e InsufficientReadQuorum) Unwrap() error {
}
// InsufficientWriteQuorum storage cannot satisfy quorum for write operation.
type InsufficientWriteQuorum struct{}
type InsufficientWriteQuorum GenericError
func (e InsufficientWriteQuorum) Error() string {
return "Storage resources are insufficient for the write operation."
return "Storage resources are insufficient for the write operation " + e.Bucket + "/" + e.Object
}
// Unwrap the error.
@@ -194,6 +212,11 @@ type GenericError struct {
Err error
}
// Unwrap the error to its underlying error.
func (e GenericError) Unwrap() error {
return e.Err
}
// InvalidArgument incorrect input argument
type InvalidArgument GenericError