mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Fix object deletion where quorum is not available (#5709)
Object deletion should not be possible if quorum is not available. This PR updates deleteObject() to check for quorum errors before proceeding with object deletion. Fixes #5535
This commit is contained in:
parent
de44be86d0
commit
58291acb8d
@ -730,17 +730,20 @@ func (xl xlObjects) deleteObject(bucket, object string) error {
|
||||
|
||||
isDir := hasSuffix(object, slashSeparator)
|
||||
|
||||
// If its a directory request, no need to read metadata.
|
||||
if !isDir {
|
||||
// Read metadata associated with the object from all disks.
|
||||
metaArr, errs := readAllXLMetadata(xl.getDisks(), bucket, object)
|
||||
|
||||
// get Quorum for this object
|
||||
_, writeQuorum, err = objectQuorumFromMeta(xl, metaArr, errs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = reduceWriteQuorumErrs(errs, objectOpIgnoredErrs, writeQuorum)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// WriteQuorum is defaulted to N/2 + 1 for directories
|
||||
writeQuorum = len(xl.getDisks())/2 + 1
|
||||
}
|
||||
|
||||
@ -755,16 +758,16 @@ func (xl xlObjects) deleteObject(bucket, object string) error {
|
||||
wg.Add(1)
|
||||
go func(index int, disk StorageAPI, isDir bool) {
|
||||
defer wg.Done()
|
||||
var err error
|
||||
var e error
|
||||
if isDir {
|
||||
// DeleteFile() simply tries to remove a directory
|
||||
// and will succeed only if that directory is empty.
|
||||
err = disk.DeleteFile(bucket, object)
|
||||
e = disk.DeleteFile(bucket, object)
|
||||
} else {
|
||||
err = cleanupDir(disk, bucket, object)
|
||||
e = cleanupDir(disk, bucket, object)
|
||||
}
|
||||
if err != nil && errors.Cause(err) != errVolumeNotFound {
|
||||
dErrs[index] = err
|
||||
if e != nil && errors.Cause(e) != errVolumeNotFound {
|
||||
dErrs[index] = e
|
||||
}
|
||||
}(index, disk, isDir)
|
||||
}
|
||||
@ -772,6 +775,7 @@ func (xl xlObjects) deleteObject(bucket, object string) error {
|
||||
// Wait for all routines to finish.
|
||||
wg.Wait()
|
||||
|
||||
// return errors if any during deletion
|
||||
return reduceWriteQuorumErrs(dErrs, objectOpIgnoredErrs, writeQuorum)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user