Avoid double bucket validation in DeleteObjectHandler (#6720)

On a heavily loaded server, getBucketInfo() becomes slow,
one can easily observe deleting an object causes many
additional network calls.

This PR is to let the underlying call return the actual
error and write it back to the client.
This commit is contained in:
Harshavardhana
2018-10-30 16:07:57 -07:00
committed by kannappanr
parent 9fe51e392b
commit 36990aeafd
3 changed files with 15 additions and 18 deletions

View File

@@ -2091,21 +2091,18 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.
}
return
}
} else {
getBucketInfo := objectAPI.GetBucketInfo
if api.CacheAPI() != nil {
getBucketInfo = api.CacheAPI().GetBucketInfo
}
if _, err := getBucketInfo(ctx, bucket); err != nil {
writeErrorResponse(w, toAPIErrorCode(err), r.URL)
return
}
}
// http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
// Ignore delete object errors while replying to client, since we are
// suppposed to reply only 204. Additionally log the error for
// investigation.
deleteObject(ctx, objectAPI, api.CacheAPI(), bucket, object, r)
if err := deleteObject(ctx, objectAPI, api.CacheAPI(), bucket, object, r); err != nil {
switch toAPIErrorCode(err) {
case ErrNoSuchBucket:
// When bucket doesn't exist specially handle it.
writeErrorResponse(w, ErrNoSuchBucket, r.URL)
return
}
logger.LogIf(ctx, err)
// Ignore delete object errors while replying to client, since we are suppposed to reply only 204.
}
writeSuccessNoContent(w)
}