Fix FS remove bucket regression bug (#2693)

master
Anis Elleuch 8 years ago committed by Harshavardhana
parent 19e01ceb19
commit a84548d7ea
  1. 14
      cmd/fs-v1.go
  2. 3
      cmd/object-common.go
  3. 1
      cmd/routers.go

@ -117,26 +117,24 @@ func (fs fsObjects) Shutdown() error {
_, err := fs.storage.ListDir(minioMetaBucket, mpartMetaPrefix) _, err := fs.storage.ListDir(minioMetaBucket, mpartMetaPrefix)
if err != errFileNotFound { if err != errFileNotFound {
// A nil err means that multipart directory is not empty hence do not remove '.minio.sys' volume. // A nil err means that multipart directory is not empty hence do not remove '.minio.sys' volume.
// A non nil err means that an unexpected error occurred // A non nil err means that an unexpected error occured
return err return toObjectErr(traceError(err))
} }
// List if there are any bucket configuration entries. // List if there are any bucket configuration entries.
_, err = fs.storage.ListDir(minioMetaBucket, bucketConfigPrefix) _, err = fs.storage.ListDir(minioMetaBucket, bucketConfigPrefix)
if err != errFileNotFound { if err != errFileNotFound {
// A nil err means that bucket config directory is not empty hence do not remove '.minio.sys' volume. // A nil err means that bucket config directory is not empty hence do not remove '.minio.sys' volume.
// A non nil err means that an unexpected error occurred // A non nil err means that an unexpected error occured
return err return toObjectErr(traceError(err))
} }
// Cleanup everything else. // Cleanup everything else.
prefix := "" prefix := ""
if err = cleanupDir(fs.storage, minioMetaBucket, prefix); err != nil { if err = cleanupDir(fs.storage, minioMetaBucket, prefix); err != nil {
errorIf(err, "Unable to cleanup minio meta bucket")
return err return err
} }
if err = fs.storage.DeleteVol(minioMetaBucket); err != nil { if err = fs.storage.DeleteVol(minioMetaBucket); err != nil {
if err != errVolumeNotEmpty { if err != errVolumeNotEmpty {
errorIf(err, "Unable to delete minio meta bucket %s", minioMetaBucket) return toObjectErr(traceError(err))
return err
} }
} }
// Successful. // Successful.
@ -220,7 +218,7 @@ func (fs fsObjects) DeleteBucket(bucket string) error {
return toObjectErr(traceError(err), bucket) return toObjectErr(traceError(err), bucket)
} }
// Cleanup all the previously incomplete multiparts. // Cleanup all the previously incomplete multiparts.
if err := cleanupDir(fs.storage, path.Join(minioMetaBucket, mpartMetaPrefix), bucket); err != nil && err != errVolumeNotFound { if err := cleanupDir(fs.storage, path.Join(minioMetaBucket, mpartMetaPrefix), bucket); err != nil && errorCause(err) != errVolumeNotFound {
return toObjectErr(err, bucket) return toObjectErr(err, bucket)
} }
return nil return nil

@ -216,7 +216,8 @@ func cleanupDir(storage StorageAPI, volume, dirPath string) error {
delFunc = func(entryPath string) error { delFunc = func(entryPath string) error {
if !strings.HasSuffix(entryPath, slashSeparator) { if !strings.HasSuffix(entryPath, slashSeparator) {
// Delete the file entry. // Delete the file entry.
return storage.DeleteFile(volume, entryPath) err := storage.DeleteFile(volume, entryPath)
return traceError(err)
} }
// If it's a directory, list and call delFunc() for each entry. // If it's a directory, list and call delFunc() for each entry.

@ -62,6 +62,7 @@ func newObjectLayer(disks, ignoredDisks []string) (ObjectLayer, error) {
globalShutdownCBs.AddObjectLayerCB(func() errCode { globalShutdownCBs.AddObjectLayerCB(func() errCode {
if objAPI != nil { if objAPI != nil {
if sErr := objAPI.Shutdown(); sErr != nil { if sErr := objAPI.Shutdown(); sErr != nil {
errorIf(err, "Unable to shutdown object API.")
return exitFailure return exitFailure
} }
} }

Loading…
Cancel
Save