diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go index 021b48d80..16b329697 100644 --- a/cmd/bucket-replication.go +++ b/cmd/bucket-replication.go @@ -261,15 +261,16 @@ func replicateObject(ctx context.Context, objInfo ObjectInfo, objectAPI ObjectLa // - event.ObjectReplicationNotTracked // - event.ObjectReplicationMissedThreshold // - event.ObjectReplicationReplicatedAfterThreshold + var eventName = event.ObjectReplicationComplete if replicationStatus == replication.Failed { - sendEvent(eventArgs{ - EventName: event.ObjectReplicationFailed, - BucketName: bucket, - Object: objInfo, - Host: "Internal: [Replication]", - }) + eventName = event.ObjectReplicationFailed } - + sendEvent(eventArgs{ + EventName: eventName, + BucketName: bucket, + Object: objInfo, + Host: "Internal: [Replication]", + }) objInfo.metadataOnly = true // Perform only metadata updates. if _, err = objectAPI.CopyObject(ctx, bucket, object, bucket, object, objInfo, ObjectOptions{ VersionID: objInfo.VersionID, diff --git a/pkg/event/name.go b/pkg/event/name.go index 5a8b07f69..20386f8f2 100644 --- a/pkg/event/name.go +++ b/pkg/event/name.go @@ -24,6 +24,7 @@ import ( // Name - event type enum. // Refer http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations // for most basic values we have since extend this and its not really much applicable other than a reference point. +// "s3:Replication:OperationCompletedReplication" is a MinIO extension. type Name int // Values of event Name @@ -47,6 +48,7 @@ const ( BucketRemoved ObjectReplicationAll ObjectReplicationFailed + ObjectReplicationComplete ObjectReplicationMissedThreshold ObjectReplicationReplicatedAfterThreshold ObjectReplicationNotTracked @@ -69,6 +71,7 @@ func (name Name) Expand() []Name { ObjectCreatedCompleteMultipartUpload, ObjectCreatedCopy, ObjectCreatedPost, ObjectCreatedPut, ObjectCreatedPutRetention, ObjectCreatedPutLegalHold, + ObjectReplicationComplete, ObjectReplicationFailed, } case ObjectRemovedAll: return []Name{ @@ -78,6 +81,7 @@ func (name Name) Expand() []Name { case ObjectReplicationAll: return []Name{ ObjectReplicationFailed, + ObjectReplicationComplete, ObjectReplicationNotTracked, ObjectReplicationMissedThreshold, ObjectReplicationReplicatedAfterThreshold, @@ -124,8 +128,12 @@ func (name Name) String() string { return "s3:ObjectRemoved:Delete" case ObjectRemovedDeleteMarkerCreated: return "s3:ObjectRemoved:DeleteMarkerCreated" + case ObjectReplicationAll: + return "s3:Replication:*" case ObjectReplicationFailed: return "s3:Replication:OperationFailedReplication" + case ObjectReplicationComplete: + return "s3:Replication:OperationCompletedReplication" case ObjectReplicationNotTracked: return "s3:Replication:OperationNotTracked" case ObjectReplicationMissedThreshold: @@ -220,6 +228,8 @@ func ParseName(s string) (Name, error) { return ObjectReplicationAll, nil case "s3:Replication:OperationFailedReplication": return ObjectReplicationFailed, nil + case "s3:Replication:OperationCompletedReplication": + return ObjectReplicationComplete, nil case "s3:Replication:OperationMissedThreshold": return ObjectReplicationMissedThreshold, nil case "s3:Replication:OperationReplicatedAfterThreshold": diff --git a/pkg/event/name_test.go b/pkg/event/name_test.go index 0cc8b6e9a..042f017a3 100644 --- a/pkg/event/name_test.go +++ b/pkg/event/name_test.go @@ -32,7 +32,7 @@ func TestNameExpand(t *testing.T) { {BucketRemoved, []Name{BucketRemoved}}, {ObjectAccessedAll, []Name{ObjectAccessedGet, ObjectAccessedHead, ObjectAccessedGetRetention, ObjectAccessedGetLegalHold}}, {ObjectCreatedAll, []Name{ObjectCreatedCompleteMultipartUpload, ObjectCreatedCopy, - ObjectCreatedPost, ObjectCreatedPut, ObjectCreatedPutRetention, ObjectCreatedPutLegalHold}}, + ObjectCreatedPost, ObjectCreatedPut, ObjectCreatedPutRetention, ObjectCreatedPutLegalHold, ObjectReplicationComplete, ObjectReplicationFailed}}, {ObjectRemovedAll, []Name{ObjectRemovedDelete, ObjectRemovedDeleteMarkerCreated}}, {ObjectAccessedHead, []Name{ObjectAccessedHead}}, }