Report correct error when O_DIRECT is not supported (#9545)

fixes #9537
This commit is contained in:
Harshavardhana
2020-05-07 16:12:16 -07:00
committed by GitHub
parent 0674c0075e
commit 2dc46cb153
7 changed files with 47 additions and 6 deletions

View File

@@ -738,6 +738,12 @@ func registerStorageRESTHandlers(router *mux.Router, endpointZones EndpointZones
}
storage, err := newPosix(endpoint.Path)
if err != nil {
if err == errMinDiskSize {
logger.Fatal(config.ErrUnableToWriteInBackend(err).Hint(err.Error()), "Unable to initialize backend")
} else if err == errUnsupportedDisk {
hint := fmt.Sprintf("'%s' does not support O_DIRECT flags, refusing to use", endpoint.Path)
logger.Fatal(config.ErrUnsupportedBackend(err).Hint(hint), "Unable to initialize backend")
}
// Show a descriptive error with a hint about how to fix it.
var username string
if u, err := user.Current(); err == nil {
@@ -747,7 +753,7 @@ func registerStorageRESTHandlers(router *mux.Router, endpointZones EndpointZones
}
hint := fmt.Sprintf("Run the following command to add the convenient permissions: `sudo chown %s %s && sudo chmod u+rxw %s`",
username, endpoint.Path, endpoint.Path)
logger.Fatal(config.ErrUnableToWriteInBackend(err).Msg(err.Error()).Hint(hint),
logger.Fatal(config.ErrUnableToWriteInBackend(err).Hint(hint),
"Unable to initialize posix backend")
}