diff --git a/cmd/config-migrate_test.go b/cmd/config-migrate_test.go index 419b03589..f984d8959 100644 --- a/cmd/config-migrate_test.go +++ b/cmd/config-migrate_test.go @@ -174,10 +174,6 @@ func TestServerConfigMigrateV2toV28(t *testing.T) { } defer os.RemoveAll(fsDir) - globalObjLayerMutex.Lock() - globalObjectAPI = objLayer - globalObjLayerMutex.Unlock() - configPath := rootPath + "/" + minioConfigFile // Create a corrupted config file @@ -203,12 +199,12 @@ func TestServerConfigMigrateV2toV28(t *testing.T) { t.Fatal("Unexpected error: ", err) } - if err := migrateConfigToMinioSys(); err != nil { + if err := migrateConfigToMinioSys(objLayer); err != nil { t.Fatal("Unexpected error: ", err) } // Initialize server config and check again if everything is fine - if err := loadConfig(newObjectLayerFn()); err != nil { + if err := loadConfig(objLayer); err != nil { t.Fatalf("Unable to initialize from updated config file %s", err) } diff --git a/cmd/config.go b/cmd/config.go index c4e920102..e69c10d2b 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -202,9 +202,9 @@ func NewConfigSys() *ConfigSys { } // Migrates ${HOME}/.minio/config.json to '/.minio.sys/config/config.json' -func migrateConfigToMinioSys() error { +func migrateConfigToMinioSys(objAPI ObjectLayer) error { // Verify if backend already has the file. - if err := checkServerConfig(context.Background(), newObjectLayerFn()); err != errConfigNotFound { + if err := checkServerConfig(context.Background(), objAPI); err != errConfigNotFound { return err } // if errConfigNotFound proceed to migrate.. @@ -213,7 +213,7 @@ func migrateConfigToMinioSys() error { return err } - return saveServerConfig(newObjectLayerFn(), config) + return saveServerConfig(objAPI, config) } // Initialize and load config from remote etcd or local config directory @@ -236,7 +236,7 @@ func initConfig(objAPI ObjectLayer) error { } // Migrates ${HOME}/.minio/config.json to '/.minio.sys/config/config.json' - if err := migrateConfigToMinioSys(); err != nil { + if err := migrateConfigToMinioSys(objAPI); err != nil { return err } } diff --git a/cmd/policy.go b/cmd/policy.go index 192aebc28..43a9462ab 100644 --- a/cmd/policy.go +++ b/cmd/policy.go @@ -77,10 +77,6 @@ func (sys *PolicySys) Remove(bucketName string) { // IsAllowed - checks given policy args is allowed to continue the Rest API. func (sys *PolicySys) IsAllowed(args policy.Args) bool { - if sys == nil { - return args.IsOwner - } - sys.RLock() defer sys.RUnlock() diff --git a/cmd/server-main.go b/cmd/server-main.go index cf2417cf6..74f43753b 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -313,10 +313,6 @@ func serverMain(ctx *cli.Context) { logger.FatalIf(err, "Unable to initialize backend") } - globalObjLayerMutex.Lock() - globalObjectAPI = newObject - globalObjLayerMutex.Unlock() - // Populate existing buckets to the etcd backend if globalDNSConfig != nil { initFederatorBackend(newObject) @@ -326,7 +322,7 @@ func serverMain(ctx *cli.Context) { globalConfigSys = NewConfigSys() // Initialize config system. - if err = globalConfigSys.Init(newObjectLayerFn()); err != nil { + if err = globalConfigSys.Init(newObject); err != nil { logger.Fatal(err, "Unable to initialize config system") } @@ -347,7 +343,7 @@ func serverMain(ctx *cli.Context) { globalPolicySys = NewPolicySys() // Initialize policy system. - if err := globalPolicySys.Init(newObjectLayerFn()); err != nil { + if err := globalPolicySys.Init(newObject); err != nil { logger.Fatal(err, "Unable to initialize policy system") } @@ -355,10 +351,14 @@ func serverMain(ctx *cli.Context) { globalNotificationSys = NewNotificationSys(globalServerConfig, globalEndpoints) // Initialize notification system. - if err := globalNotificationSys.Init(newObjectLayerFn()); err != nil { + if err := globalNotificationSys.Init(newObject); err != nil { logger.Fatal(err, "Unable to initialize notification system") } + globalObjLayerMutex.Lock() + globalObjectAPI = newObject + globalObjLayerMutex.Unlock() + // Prints the formatted startup message once object layer is initialized. apiEndpoints := getAPIEndpoints(globalMinioAddr) printStartupMessage(apiEndpoints)