Allow backward compatible way to load creds from config.json (#6435)

Print warning message for users to migrate to newer style of distributed
deployment by always setting credentials as ENVs.

Fixes #6434
master
Harshavardhana 6 years ago committed by Dee Koder
parent e7a4512a90
commit 19202bae81
  1. 5
      cmd/common-main.go
  2. 2
      cmd/config.go
  3. 29
      cmd/server-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 {

@ -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
}

@ -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.

Loading…
Cancel
Save