diff --git a/cmd/bucket-notification-handlers.go b/cmd/bucket-notification-handlers.go index 3e8738295..5a0014ee8 100644 --- a/cmd/bucket-notification-handlers.go +++ b/cmd/bucket-notification-handlers.go @@ -177,6 +177,10 @@ func (api objectAPIHandlers) ListenBucketNotificationHandler(w http.ResponseWrit return } + if !objAPI.IsListenBucketSupported() { + writeErrorResponse(w, ErrNotImplemented, r.URL, guessIsBrowserReq(r)) + return + } vars := mux.Vars(r) bucketName := vars["bucket"] diff --git a/cmd/dummy-object-layer_test.go b/cmd/dummy-object-layer_test.go index 4d0ad145c..a769b6d07 100644 --- a/cmd/dummy-object-layer_test.go +++ b/cmd/dummy-object-layer_test.go @@ -154,6 +154,9 @@ func (api *DummyObjectLayer) DeleteBucketPolicy(context.Context, string) (err er func (api *DummyObjectLayer) IsNotificationSupported() (b bool) { return } +func (api *DummyObjectLayer) IsListenBucketSupported() (b bool) { + return +} func (api *DummyObjectLayer) IsEncryptionSupported() (b bool) { return diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 7950afcdf..3ff454903 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -1306,6 +1306,11 @@ func (fs *FSObjects) IsNotificationSupported() bool { 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. func (fs *FSObjects) IsEncryptionSupported() bool { return true diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index d2804d0f5..dbc407b3a 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -230,7 +230,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) { // Create a new config system. globalConfigSys = NewConfigSys() - if globalEtcdClient != nil { + if globalEtcdClient != nil && gatewayName == "nas" { // Initialize server config. _ = globalConfigSys.Init(newObject) } else { @@ -281,10 +281,9 @@ func StartGateway(ctx *cli.Context, gw Gateway) { // Create new notification system. globalNotificationSys = NewNotificationSys(globalServerConfig, globalEndpoints) - if globalEtcdClient != nil { + if globalEtcdClient != nil && newObject.IsNotificationSupported() { _ = globalNotificationSys.Init(newObject) } - // Once endpoints are finalized, initialize the new object api. globalObjLayerMutex.Lock() globalObjectAPI = newObject diff --git a/cmd/gateway-unsupported.go b/cmd/gateway-unsupported.go index 14b5505ab..74edac97a 100644 --- a/cmd/gateway-unsupported.go +++ b/cmd/gateway-unsupported.go @@ -132,6 +132,11 @@ func (a GatewayUnsupported) IsNotificationSupported() bool { 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. func (a GatewayUnsupported) IsEncryptionSupported() bool { return false diff --git a/cmd/gateway/nas/gateway-nas.go b/cmd/gateway/nas/gateway-nas.go index 03b8c23a0..f53c5e491 100644 --- a/cmd/gateway/nas/gateway-nas.go +++ b/cmd/gateway/nas/gateway-nas.go @@ -116,6 +116,11 @@ func (g *NAS) Production() bool { 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. type nasObjects struct { minio.ObjectLayer diff --git a/cmd/object-api-interface.go b/cmd/object-api-interface.go index 3e98fbdb9..829b99593 100644 --- a/cmd/object-api-interface.go +++ b/cmd/object-api-interface.go @@ -94,6 +94,7 @@ type ObjectLayer interface { // Supported operations check IsNotificationSupported() bool + IsListenBucketSupported() bool IsEncryptionSupported() bool // Compression support check. diff --git a/cmd/xl-sets.go b/cmd/xl-sets.go index de5d5cbdb..175f9b9ad 100644 --- a/cmd/xl-sets.go +++ b/cmd/xl-sets.go @@ -516,6 +516,11 @@ func (s *xlSets) IsNotificationSupported() bool { 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. func (s *xlSets) IsEncryptionSupported() bool { return s.getHashedSet("").IsEncryptionSupported() diff --git a/cmd/xl-v1-bucket.go b/cmd/xl-v1-bucket.go index c0f0e8c02..a002d0a73 100644 --- a/cmd/xl-v1-bucket.go +++ b/cmd/xl-v1-bucket.go @@ -294,6 +294,11 @@ func (xl xlObjects) IsNotificationSupported() bool { 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. func (xl xlObjects) IsEncryptionSupported() bool { return true