Delete bucket listener config file from disk (#3016)

master
Aditya Manthramurthy 8 years ago committed by Harshavardhana
parent c21ac80268
commit 8876e0a80a
  1. 7
      cmd/bucket-handlers.go
  2. 21
      cmd/event-notifier.go

@ -562,10 +562,13 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.
} }
// Delete bucket access policy, if present - ignore any errors. // Delete bucket access policy, if present - ignore any errors.
removeBucketPolicy(bucket, objectAPI) _ = removeBucketPolicy(bucket, objectAPI)
// Delete notification config, if present - ignore any errors. // Delete notification config, if present - ignore any errors.
removeNotificationConfig(bucket, objectAPI) _ = removeNotificationConfig(bucket, objectAPI)
// Delete listener config, if present - ignore any errors.
_ = removeListenerConfig(bucket, objectAPI)
// Write success response. // Write success response.
writeSuccessNoContent(w) writeSuccessNoContent(w)

@ -205,19 +205,21 @@ func (en *eventNotifier) GetBucketListenerConfig(bucket string) []listenerConfig
func (en *eventNotifier) SetBucketListenerConfig(bucket string, lcfg []listenerConfig) error { func (en *eventNotifier) SetBucketListenerConfig(bucket string, lcfg []listenerConfig) error {
en.internal.rwMutex.Lock() en.internal.rwMutex.Lock()
defer en.internal.rwMutex.Unlock() defer en.internal.rwMutex.Unlock()
if lcfg == nil { if len(lcfg) == 0 {
delete(en.internal.listenerConfigs, bucket) delete(en.internal.listenerConfigs, bucket)
} else { } else {
en.internal.listenerConfigs[bucket] = lcfg en.internal.listenerConfigs[bucket] = lcfg
} }
en.internal.targets = make(map[string]*listenerLogger) en.internal.targets = make(map[string]*listenerLogger)
for _, lc := range lcfg { for _, elcArr := range en.internal.listenerConfigs {
logger, err := newListenerLogger(lc.TopicConfig.TopicARN, for _, elcElem := range elcArr {
lc.TargetServer) currArn := elcElem.TopicConfig.TopicARN
logger, err := newListenerLogger(currArn, elcElem.TargetServer)
if err != nil { if err != nil {
return err return err
} }
en.internal.targets[lc.TopicConfig.TopicARN] = logger en.internal.targets[currArn] = logger
}
} }
return nil return nil
} }
@ -443,6 +445,15 @@ func persistListenerConfig(bucket string, lcfg []listenerConfig, obj ObjectLayer
return err return err
} }
// Remove listener configuration from storage layer. Used when a
// bucket is deleted.
func removeListenerConfig(bucket string, obj ObjectLayer) error {
// make the path
lcPath := path.Join(bucketConfigPrefix, bucket, bucketListenerConfig)
// remove it
return obj.DeleteObject(minioMetaBucket, lcPath)
}
// loads all bucket notifications if present. // loads all bucket notifications if present.
func loadAllBucketNotifications(objAPI ObjectLayer) (map[string]*notificationConfig, map[string][]listenerConfig, error) { func loadAllBucketNotifications(objAPI ObjectLayer) (map[string]*notificationConfig, map[string][]listenerConfig, error) {
// List buckets to proceed loading all notification configuration. // List buckets to proceed loading all notification configuration.

Loading…
Cancel
Save