initialize object layer right after config has loaded

master
Harshavardhana 4 years ago
parent b07df5cae1
commit d6d770c1b1
  1. 4
      cmd/notification.go
  2. 10
      cmd/server-main.go

@ -590,7 +590,7 @@ func (sys *NotificationSys) DeleteBucketMetadata(ctx context.Context, bucketName
} }
// Loads notification policies for all buckets into NotificationSys. // Loads notification policies for all buckets into NotificationSys.
func (sys *NotificationSys) load(buckets []BucketInfo, objAPI ObjectLayer) error { func (sys *NotificationSys) load(buckets []BucketInfo) error {
for _, bucket := range buckets { for _, bucket := range buckets {
ctx := logger.SetReqInfo(GlobalContext, &logger.ReqInfo{BucketName: bucket.Name}) ctx := logger.SetReqInfo(GlobalContext, &logger.ReqInfo{BucketName: bucket.Name})
config, err := globalBucketMetadataSys.GetNotificationConfig(bucket.Name) config, err := globalBucketMetadataSys.GetNotificationConfig(bucket.Name)
@ -632,7 +632,7 @@ func (sys *NotificationSys) Init(ctx context.Context, buckets []BucketInfo, objA
} }
}() }()
go logger.LogIf(ctx, sys.load(buckets, objAPI)) go logger.LogIf(ctx, sys.load(buckets))
return nil return nil
} }

@ -330,6 +330,11 @@ func initAllSubsystems(ctx context.Context, newObject ObjectLayer) (err error) {
logger.LogIf(ctx, fmt.Errorf("Unable to initialize config, some features may be missing %w", err)) logger.LogIf(ctx, fmt.Errorf("Unable to initialize config, some features may be missing %w", err))
} }
// Once the config is fully loaded, initialize the new object layer.
globalObjLayerMutex.Lock()
globalObjectAPI = newObject
globalObjLayerMutex.Unlock()
// Initialize IAM store // Initialize IAM store
globalIAMSys.InitStore(newObject) globalIAMSys.InitStore(newObject)
@ -501,11 +506,6 @@ func serverMain(ctx *cli.Context) {
} }
} }
// Once the config is fully loaded, initialize the new object layer.
globalObjLayerMutex.Lock()
globalObjectAPI = newObject
globalObjLayerMutex.Unlock()
// Initialize users credentials and policies in background right after config has initialized. // Initialize users credentials and policies in background right after config has initialized.
go globalIAMSys.Init(GlobalContext, newObject) go globalIAMSys.Init(GlobalContext, newObject)

Loading…
Cancel
Save