Return detailed msg for notification errors (#5913)

master
Anis Elleuch 7 years ago committed by Dee Koder
parent c1f1fa3cc8
commit c525424179
  1. 18
      cmd/common-main.go
  2. 6
      cmd/gateway-main.go
  3. 2
      cmd/net.go
  4. 4
      cmd/server-main.go

@ -44,10 +44,10 @@ func checkUpdate(mode string) {
func initConfig() { func initConfig() {
// Config file does not exist, we create it fresh and return upon success. // Config file does not exist, we create it fresh and return upon success.
if isFile(getConfigFile()) { if isFile(getConfigFile()) {
logger.FatalIf(migrateConfig(), "Config migration failed.") logger.FatalIf(migrateConfig(), "Config migration failed")
logger.FatalIf(loadConfig(), "Unable to load the configuration file") logger.FatalIf(loadConfig(), "Unable to load the configuration file")
} else { } else {
logger.FatalIf(newConfig(), "Unable to initialize minio config for the first time.") logger.FatalIf(newConfig(), "Unable to initialize minio config for the first time")
logger.Info("Created minio configuration file successfully at " + getConfigDir()) logger.Info("Created minio configuration file successfully at " + getConfigDir())
} }
} }
@ -71,12 +71,12 @@ func handleCommonCmdArgs(ctx *cli.Context) {
// default config directory. // default config directory.
configDir = getConfigDir() configDir = getConfigDir()
if configDir == "" { if configDir == "" {
logger.FatalIf(errors.New("missing option"), "config-dir option must be provided.") logger.FatalIf(errors.New("missing option"), "config-dir option must be provided")
} }
} }
if configDir == "" { if configDir == "" {
logger.FatalIf(errors.New("empty directory"), "Configuration directory cannot be empty.") logger.FatalIf(errors.New("empty directory"), "Configuration directory cannot be empty")
} }
// Disallow relative paths, figure out absolute paths. // Disallow relative paths, figure out absolute paths.
@ -140,7 +140,7 @@ func handleCommonEnvVars() {
if excludes := os.Getenv("MINIO_CACHE_EXCLUDE"); excludes != "" { if excludes := os.Getenv("MINIO_CACHE_EXCLUDE"); excludes != "" {
excludeList, err := parseCacheExcludes(strings.Split(excludes, cacheEnvDelimiter)) excludeList, err := parseCacheExcludes(strings.Split(excludes, cacheEnvDelimiter))
if err != nil { if err != nil {
logger.Fatal(err, "Unable to parse MINIO_CACHE_EXCLUDE value (`%s`).", excludes) logger.Fatal(err, "Unable to parse MINIO_CACHE_EXCLUDE value (`%s`)", excludes)
} }
globalCacheExcludes = excludeList globalCacheExcludes = excludeList
} }
@ -165,25 +165,25 @@ func handleCommonEnvVars() {
// Check for environment variables and parse into storageClass struct // Check for environment variables and parse into storageClass struct
if ssc := os.Getenv(standardStorageClassEnv); ssc != "" { if ssc := os.Getenv(standardStorageClassEnv); ssc != "" {
globalStandardStorageClass, err = parseStorageClass(ssc) globalStandardStorageClass, err = parseStorageClass(ssc)
logger.FatalIf(err, "Invalid value set in environment variable %s.", standardStorageClassEnv) logger.FatalIf(err, "Invalid value set in environment variable %s", standardStorageClassEnv)
} }
if rrsc := os.Getenv(reducedRedundancyStorageClassEnv); rrsc != "" { if rrsc := os.Getenv(reducedRedundancyStorageClassEnv); rrsc != "" {
globalRRStorageClass, err = parseStorageClass(rrsc) globalRRStorageClass, err = parseStorageClass(rrsc)
logger.FatalIf(err, "Invalid value set in environment variable %s.", reducedRedundancyStorageClassEnv) logger.FatalIf(err, "Invalid value set in environment variable %s", reducedRedundancyStorageClassEnv)
} }
// Validation is done after parsing both the storage classes. This is needed because we need one // Validation is done after parsing both the storage classes. This is needed because we need one
// storage class value to deduce the correct value of the other storage class. // storage class value to deduce the correct value of the other storage class.
if globalRRStorageClass.Scheme != "" { if globalRRStorageClass.Scheme != "" {
err = validateParity(globalStandardStorageClass.Parity, globalRRStorageClass.Parity) err = validateParity(globalStandardStorageClass.Parity, globalRRStorageClass.Parity)
logger.FatalIf(err, "Invalid value set in environment variable %s.", reducedRedundancyStorageClassEnv) logger.FatalIf(err, "Invalid value set in environment variable %s", reducedRedundancyStorageClassEnv)
globalIsStorageClass = true globalIsStorageClass = true
} }
if globalStandardStorageClass.Scheme != "" { if globalStandardStorageClass.Scheme != "" {
err = validateParity(globalStandardStorageClass.Parity, globalRRStorageClass.Parity) err = validateParity(globalStandardStorageClass.Parity, globalRRStorageClass.Parity)
logger.FatalIf(err, "Invalid value set in environment variable %s.", standardStorageClassEnv) logger.FatalIf(err, "Invalid value set in environment variable %s", standardStorageClassEnv)
globalIsStorageClass = true globalIsStorageClass = true
} }
} }

@ -109,7 +109,7 @@ func init() {
// StartGateway - handler for 'minio gateway <name>'. // StartGateway - handler for 'minio gateway <name>'.
func StartGateway(ctx *cli.Context, gw Gateway) { func StartGateway(ctx *cli.Context, gw Gateway) {
if gw == nil { if gw == nil {
logger.FatalIf(errUnexpected, "Gateway implementation not initialized, exiting.") logger.FatalIf(errUnexpected, "Gateway implementation not initialized")
} }
// Disable logging until gateway initialization is complete, any // Disable logging until gateway initialization is complete, any
@ -156,7 +156,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
} }
// Create certs path. // Create certs path.
logger.FatalIf(createConfigDir(), "Unable to create configuration directories.") logger.FatalIf(createConfigDir(), "Unable to create configuration directories")
// Initialize gateway config. // Initialize gateway config.
initConfig() initConfig()
@ -173,7 +173,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
// Create new notification system. // Create new notification system.
globalNotificationSys, err = NewNotificationSys(globalServerConfig, EndpointList{}) globalNotificationSys, err = NewNotificationSys(globalServerConfig, EndpointList{})
logger.FatalIf(err, "Unable to create new notification system.") logger.FatalIf(err, "Unable to create new notification system")
// Create new policy system. // Create new policy system.
globalPolicySys = NewPolicySys() globalPolicySys = NewPolicySys()

@ -48,7 +48,7 @@ func mustSplitHostPort(hostPort string) (host, port string) {
func mustGetLocalIP4() (ipList set.StringSet) { func mustGetLocalIP4() (ipList set.StringSet) {
ipList = set.NewStringSet() ipList = set.NewStringSet()
addrs, err := net.InterfaceAddrs() addrs, err := net.InterfaceAddrs()
logger.FatalIf(err, "Unable to get IP addresses of this host.") logger.FatalIf(err, "Unable to get IP addresses of this host")
for _, addr := range addrs { for _, addr := range addrs {
var ip net.IP var ip net.IP

@ -246,13 +246,13 @@ func serverMain(ctx *cli.Context) {
var handler http.Handler var handler http.Handler
handler, err = configureServerHandler(globalEndpoints) handler, err = configureServerHandler(globalEndpoints)
if err != nil { if err != nil {
logger.Fatal(uiErrUnexpectedError(err), "Unable to configure one of server's RPC services.") logger.Fatal(uiErrUnexpectedError(err), "Unable to configure one of server's RPC services")
} }
// Create new notification system. // Create new notification system.
globalNotificationSys, err = NewNotificationSys(globalServerConfig, globalEndpoints) globalNotificationSys, err = NewNotificationSys(globalServerConfig, globalEndpoints)
if err != nil { if err != nil {
logger.Fatal(uiErrUnexpectedError(err), "Unable to create new notification system.") logger.Fatal(err, "Unable to initialize the notification system")
} }
// Create new policy system. // Create new policy system.

Loading…
Cancel
Save