diff --git a/cmd/common-main.go b/cmd/common-main.go index 4590a92d8..e7926f5f5 100644 --- a/cmd/common-main.go +++ b/cmd/common-main.go @@ -114,11 +114,6 @@ func handleCommonEnvVars() { globalActiveCred = cred } - // In distributed setup users need to set ENVs always. - if !globalIsEnvCreds && globalIsDistXL { - logger.Fatal(uiErrEnvCredentialsMissingServer(nil), "Unable to start distributed server mode") - } - if browser := os.Getenv("MINIO_BROWSER"); browser != "" { browserFlag, err := ParseBoolFlag(browser) if err != nil { diff --git a/cmd/config.go b/cmd/config.go index 2cf6ffc2e..af8cef7ef 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -55,7 +55,7 @@ func saveServerConfig(ctx context.Context, objAPI ObjectLayer, config *serverCon configFile := path.Join(minioConfigPrefix, minioConfigFile) if globalEtcdClient != nil { timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Minute) - _, err := globalEtcdClient.Put(timeoutCtx, configFile, string(data)) + _, err = globalEtcdClient.Put(timeoutCtx, configFile, string(data)) defer cancel() return err } diff --git a/cmd/server-main.go b/cmd/server-main.go index cf41f3d42..ccfce32e3 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -224,11 +224,6 @@ func serverMain(ctx *cli.Context) { // Handle all server environment vars. serverHandleEnvVars() - // In distributed setup users need to set ENVs always. - if !globalIsEnvCreds && globalIsDistXL { - logger.Fatal(uiErrEnvCredentialsMissingServer(nil), "Unable to initialize minio server in distributed mode") - } - // Create certs path. logger.FatalIf(createConfigDir(), "Unable to initialize configuration files") @@ -258,9 +253,27 @@ func serverMain(ctx *cli.Context) { checkUpdate(mode) } - // Enforce ENV credentials for distributed setup such that we can create the first config. - if globalIsDistXL && !globalIsEnvCreds { - logger.Fatal(uiErrInvalidCredentials(nil), "Unable to start the server in distrbuted mode. In distributed mode we require explicit credentials.") + // FIXME: This code should be removed in future releases and we should have mandatory + // check for ENVs credentials under distributed setup. Until all users migrate we + // are intentionally providing backward compatibility. + { + // Check for backward compatibility and newer style. + if !globalIsEnvCreds && globalIsDistXL { + // Try to load old config file if any, for backward compatibility. + var config = &serverConfig{} + if _, err = Load(getConfigFile(), config); err == nil { + globalActiveCred = config.Credential + } + + if globalActiveCred.IsValid() { + // Credential is valid don't throw an error instead print a message regarding deprecation of 'config.json' + // based model and proceed to use it for now in distributed setup. + logger.Info(`Supplying credentials from your 'config.json' is **DEPRECATED**, Access key and Secret key in distributed server mode is expected to be specified with environment variables MINIO_ACCESS_KEY and MINIO_SECRET_KEY. This approach will become mandatory in future releases, please migrate to this approach soon.`) + } else { + // Credential is not available anywhere by both means, we cannot start distributed setup anymore, fail eagerly. + logger.Fatal(uiErrEnvCredentialsMissingServer(nil), "Unable to initialize distributed Minio server.") + } + } } // Set system resources to maximum.