FS/Shutdown: cleanup and delete .minio.sys during Shutdown() (#3360)

master
Krishna Srinivas 8 years ago committed by Harshavardhana
parent 694bad434c
commit bcd1a2308b
  1. 27
      cmd/fs-v1.go

@ -81,12 +81,20 @@ func newFSObjects(storage StorageAPI) (ObjectLayer, error) {
// Should be called when process shuts down. // Should be called when process shuts down.
func (fs fsObjects) Shutdown() error { func (fs fsObjects) Shutdown() error {
// List if there are any multipart entries. // List if there are any multipart entries.
_, err := fs.storage.ListDir(minioMetaBucket, mpartMetaPrefix) prefix := ""
if err != errFileNotFound { entries, err := fs.storage.ListDir(minioMetaMultipartBucket, prefix)
// A nil err means that multipart directory is not empty hence do not remove '.minio.sys' volume. if err != nil {
// A non nil err means that an unexpected error occurred // A non nil err means that an unexpected error occurred
return toObjectErr(traceError(err)) return toObjectErr(traceError(err))
} }
if len(entries) > 0 {
// Should not remove .minio.sys if there are any multipart
// uploads were found.
return nil
}
if err = fs.storage.DeleteVol(minioMetaMultipartBucket); err != nil {
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 {
@ -94,11 +102,18 @@ func (fs fsObjects) Shutdown() error {
// A non nil err means that an unexpected error occurred // A non nil err means that an unexpected error occurred
return toObjectErr(traceError(err)) return toObjectErr(traceError(err))
} }
// Cleanup everything else. // Cleanup and delete tmp bucket.
prefix := "" if err = cleanupDir(fs.storage, minioMetaTmpBucket, prefix); err != nil {
if err = cleanupDir(fs.storage, minioMetaBucket, prefix); err != nil {
return err return err
} }
if err = fs.storage.DeleteVol(minioMetaTmpBucket); err != nil {
return toObjectErr(traceError(err))
}
// Remove format.json and delete .minio.sys bucket
if err = fs.storage.DeleteFile(minioMetaBucket, fsFormatJSONFile); err != nil {
return toObjectErr(traceError(err))
}
if err = fs.storage.DeleteVol(minioMetaBucket); err != nil { if err = fs.storage.DeleteVol(minioMetaBucket); err != nil {
if err != errVolumeNotEmpty { if err != errVolumeNotEmpty {
return toObjectErr(traceError(err)) return toObjectErr(traceError(err))

Loading…
Cancel
Save