Better error when the server is unable to write in the backend (#8697)

This commit is contained in:
Anis Elleuch
2019-12-26 07:05:54 +01:00
committed by kannappanr
parent cd59a945d8
commit c31e67dcce
3 changed files with 42 additions and 8 deletions

View File

@@ -20,10 +20,12 @@ import (
"bytes"
"context"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"os/user"
"path"
"path/filepath"
"sort"
@@ -129,7 +131,15 @@ func NewFSObjectLayer(fsPath string) (ObjectLayer, error) {
if err == errMinDiskSize {
return nil, err
}
return nil, config.ErrUnableToWriteInBackend(err)
// Show a descriptive error with a hint about how to fix it.
var username string
if u, err := user.Current(); err == nil {
username = u.Username
} else {
username = "<your-username>"
}
hint := fmt.Sprintf("Use 'sudo chown %s %s && sudo chmod u+rxw %s' to provide sufficient permissions.", username, fsPath, fsPath)
return nil, config.ErrUnableToWriteInBackend(err).Hint(hint)
}
// Assign a new UUID for FS minio mode. Each server instance