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
+11 -1
View File
@@ -24,6 +24,7 @@ import (
"fmt"
"io"
"net/http"
"os/user"
"path"
"strconv"
"strings"
@@ -608,7 +609,16 @@ func registerStorageRESTHandlers(router *mux.Router, endpointZones EndpointZones
}
storage, err := newPosix(endpoint.Path)
if err != nil {
logger.Fatal(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("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).Hint(hint),
"Unable to initialize posix backend")
}