mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Delete bucket listener config file from disk (#3016)
This commit is contained in:
parent
c21ac80268
commit
8876e0a80a
@ -562,10 +562,13 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.
|
||||
}
|
||||
|
||||
// Delete bucket access policy, if present - ignore any errors.
|
||||
removeBucketPolicy(bucket, objectAPI)
|
||||
_ = removeBucketPolicy(bucket, objectAPI)
|
||||
|
||||
// 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.
|
||||
writeSuccessNoContent(w)
|
||||
|
@ -49,10 +49,10 @@ func TestPrintLockState(t *testing.T) {
|
||||
func testLockStateEquality(vliLeft, vliRight VolumeLockInfo) bool {
|
||||
|
||||
if vliLeft.Bucket != vliRight.Bucket ||
|
||||
vliLeft.Object != vliRight.Object ||
|
||||
vliLeft.LocksOnObject != vliRight.LocksOnObject ||
|
||||
vliLeft.LocksAcquiredOnObject != vliRight.LocksAcquiredOnObject ||
|
||||
vliLeft.TotalBlockedLocks != vliRight.TotalBlockedLocks {
|
||||
vliLeft.Object != vliRight.Object ||
|
||||
vliLeft.LocksOnObject != vliRight.LocksOnObject ||
|
||||
vliLeft.LocksAcquiredOnObject != vliRight.LocksAcquiredOnObject ||
|
||||
vliLeft.TotalBlockedLocks != vliRight.TotalBlockedLocks {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -205,19 +205,21 @@ func (en *eventNotifier) GetBucketListenerConfig(bucket string) []listenerConfig
|
||||
func (en *eventNotifier) SetBucketListenerConfig(bucket string, lcfg []listenerConfig) error {
|
||||
en.internal.rwMutex.Lock()
|
||||
defer en.internal.rwMutex.Unlock()
|
||||
if lcfg == nil {
|
||||
if len(lcfg) == 0 {
|
||||
delete(en.internal.listenerConfigs, bucket)
|
||||
} else {
|
||||
en.internal.listenerConfigs[bucket] = lcfg
|
||||
}
|
||||
en.internal.targets = make(map[string]*listenerLogger)
|
||||
for _, lc := range lcfg {
|
||||
logger, err := newListenerLogger(lc.TopicConfig.TopicARN,
|
||||
lc.TargetServer)
|
||||
if err != nil {
|
||||
return err
|
||||
for _, elcArr := range en.internal.listenerConfigs {
|
||||
for _, elcElem := range elcArr {
|
||||
currArn := elcElem.TopicConfig.TopicARN
|
||||
logger, err := newListenerLogger(currArn, elcElem.TargetServer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
en.internal.targets[currArn] = logger
|
||||
}
|
||||
en.internal.targets[lc.TopicConfig.TopicARN] = logger
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -443,6 +445,15 @@ func persistListenerConfig(bucket string, lcfg []listenerConfig, obj ObjectLayer
|
||||
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.
|
||||
func loadAllBucketNotifications(objAPI ObjectLayer) (map[string]*notificationConfig, map[string][]listenerConfig, error) {
|
||||
// List buckets to proceed loading all notification configuration.
|
||||
|
@ -183,4 +183,4 @@ func (c *controlAPIHandlers) LockClear(args *LockClearArgs, reply *GenericReply)
|
||||
nsMutex.ForceUnlock(args.Bucket, args.Object)
|
||||
*reply = GenericReply{}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -400,13 +400,13 @@ func TestNamespaceForceUnlockTest(t *testing.T) {
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-ch:
|
||||
// Signalled so all is fine.
|
||||
break
|
||||
case <-ch:
|
||||
// Signalled so all is fine.
|
||||
break
|
||||
|
||||
case <-time.After(100*time.Millisecond):
|
||||
// In case we hit the time out, the lock has not been cleared.
|
||||
t.Errorf("Lock not cleared.")
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
// In case we hit the time out, the lock has not been cleared.
|
||||
t.Errorf("Lock not cleared.")
|
||||
}
|
||||
|
||||
// Clean up lock.
|
||||
|
Loading…
Reference in New Issue
Block a user