fix ConfigSys and NotificationSys initialization for NAS (#6920)

This commit is contained in:
poornas 2018-12-05 14:03:42 -08:00 committed by kannappanr
parent 8fcc787cba
commit f6980c4630
9 changed files with 35 additions and 3 deletions

View File

@ -177,6 +177,10 @@ func (api objectAPIHandlers) ListenBucketNotificationHandler(w http.ResponseWrit
return return
} }
if !objAPI.IsListenBucketSupported() {
writeErrorResponse(w, ErrNotImplemented, r.URL, guessIsBrowserReq(r))
return
}
vars := mux.Vars(r) vars := mux.Vars(r)
bucketName := vars["bucket"] bucketName := vars["bucket"]

View File

@ -154,6 +154,9 @@ func (api *DummyObjectLayer) DeleteBucketPolicy(context.Context, string) (err er
func (api *DummyObjectLayer) IsNotificationSupported() (b bool) { func (api *DummyObjectLayer) IsNotificationSupported() (b bool) {
return return
} }
func (api *DummyObjectLayer) IsListenBucketSupported() (b bool) {
return
}
func (api *DummyObjectLayer) IsEncryptionSupported() (b bool) { func (api *DummyObjectLayer) IsEncryptionSupported() (b bool) {
return return

View File

@ -1306,6 +1306,11 @@ func (fs *FSObjects) IsNotificationSupported() bool {
return true return true
} }
// IsListenBucketSupported returns whether listen bucket notification is applicable for this layer.
func (fs *FSObjects) IsListenBucketSupported() bool {
return true
}
// IsEncryptionSupported returns whether server side encryption is applicable for this layer. // IsEncryptionSupported returns whether server side encryption is applicable for this layer.
func (fs *FSObjects) IsEncryptionSupported() bool { func (fs *FSObjects) IsEncryptionSupported() bool {
return true return true

View File

@ -230,7 +230,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
// Create a new config system. // Create a new config system.
globalConfigSys = NewConfigSys() globalConfigSys = NewConfigSys()
if globalEtcdClient != nil { if globalEtcdClient != nil && gatewayName == "nas" {
// Initialize server config. // Initialize server config.
_ = globalConfigSys.Init(newObject) _ = globalConfigSys.Init(newObject)
} else { } else {
@ -281,10 +281,9 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
// Create new notification system. // Create new notification system.
globalNotificationSys = NewNotificationSys(globalServerConfig, globalEndpoints) globalNotificationSys = NewNotificationSys(globalServerConfig, globalEndpoints)
if globalEtcdClient != nil { if globalEtcdClient != nil && newObject.IsNotificationSupported() {
_ = globalNotificationSys.Init(newObject) _ = globalNotificationSys.Init(newObject)
} }
// Once endpoints are finalized, initialize the new object api. // Once endpoints are finalized, initialize the new object api.
globalObjLayerMutex.Lock() globalObjLayerMutex.Lock()
globalObjectAPI = newObject globalObjectAPI = newObject

View File

@ -132,6 +132,11 @@ func (a GatewayUnsupported) IsNotificationSupported() bool {
return false return false
} }
// IsListenBucketSupported returns whether listen bucket notification is applicable for this layer.
func (a GatewayUnsupported) IsListenBucketSupported() bool {
return false
}
// IsEncryptionSupported returns whether server side encryption is applicable for this layer. // IsEncryptionSupported returns whether server side encryption is applicable for this layer.
func (a GatewayUnsupported) IsEncryptionSupported() bool { func (a GatewayUnsupported) IsEncryptionSupported() bool {
return false return false

View File

@ -116,6 +116,11 @@ func (g *NAS) Production() bool {
return true return true
} }
// IsListenBucketSupported returns whether listen bucket notification is applicable for this gateway.
func (g *NAS) IsListenBucketSupported() bool {
return false
}
// nasObjects implements gateway for Minio and S3 compatible object storage servers. // nasObjects implements gateway for Minio and S3 compatible object storage servers.
type nasObjects struct { type nasObjects struct {
minio.ObjectLayer minio.ObjectLayer

View File

@ -94,6 +94,7 @@ type ObjectLayer interface {
// Supported operations check // Supported operations check
IsNotificationSupported() bool IsNotificationSupported() bool
IsListenBucketSupported() bool
IsEncryptionSupported() bool IsEncryptionSupported() bool
// Compression support check. // Compression support check.

View File

@ -516,6 +516,11 @@ func (s *xlSets) IsNotificationSupported() bool {
return s.getHashedSet("").IsNotificationSupported() return s.getHashedSet("").IsNotificationSupported()
} }
// IsListenBucketSupported returns whether listen bucket notification is applicable for this layer.
func (s *xlSets) IsListenBucketSupported() bool {
return true
}
// IsEncryptionSupported returns whether server side encryption is applicable for this layer. // IsEncryptionSupported returns whether server side encryption is applicable for this layer.
func (s *xlSets) IsEncryptionSupported() bool { func (s *xlSets) IsEncryptionSupported() bool {
return s.getHashedSet("").IsEncryptionSupported() return s.getHashedSet("").IsEncryptionSupported()

View File

@ -294,6 +294,11 @@ func (xl xlObjects) IsNotificationSupported() bool {
return true return true
} }
// IsListenBucketSupported returns whether listen bucket notification is applicable for this layer.
func (xl xlObjects) IsListenBucketSupported() bool {
return true
}
// IsEncryptionSupported returns whether server side encryption is applicable for this layer. // IsEncryptionSupported returns whether server side encryption is applicable for this layer.
func (xl xlObjects) IsEncryptionSupported() bool { func (xl xlObjects) IsEncryptionSupported() bool {
return true return true