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
master
Nitish Tiwari 7 years ago committed by Dee Koder
parent de44be86d0
commit 58291acb8d
  1. 18
      cmd/xl-v1-object.go

@ -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…
Cancel
Save