Add transition event notification (#11047)

This is a MinIO specific extension to allow monitoring of transition events.
master
Poorna Krishnamoorthy 4 years ago committed by GitHub
parent 038bcd9079
commit 934bed47fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      cmd/bucket-lifecycle.go
  2. 5
      docs/bucket/lifecycle/README.md
  3. 21
      pkg/event/name.go

@ -356,11 +356,23 @@ func transitionObject(ctx context.Context, objectAPI ObjectLayer, objInfo Object
opts.Versioned = globalBucketVersioningSys.Enabled(oi.Bucket)
opts.VersionID = oi.VersionID
opts.TransitionStatus = lifecycle.TransitionComplete
eventName := event.ObjectTransitionComplete
if _, err = objectAPI.DeleteObject(ctx, oi.Bucket, oi.Name, opts); err != nil {
return err
}
return nil
_, err = objectAPI.DeleteObject(ctx, oi.Bucket, oi.Name, opts)
if err != nil {
eventName = event.ObjectTransitionFailed
}
// Notify object deleted event.
sendEvent(eventArgs{
EventName: eventName,
BucketName: oi.Bucket,
Object: ObjectInfo{
Name: oi.Name,
VersionID: opts.VersionID,
},
Host: "Internal: [ILM-Transition]",
})
return err
}
// getLifecycleTransitionTargetArn returns transition ARN for storage class specified in the config.

@ -127,6 +127,11 @@ aws s3api restore-object --bucket srcbucket \
--restore-request Days=3
```
### 4.1 Monitoring transition events
`s3:ObjectTransition:Complete` and `s3:ObjectTransition:Failed` events can be used to monitor transition events between the source cluster and transition tier. To watch lifecycle events, you can enable bucket notification on the source bucket with `mc event add` and specify `--event ilm` flag.
Note that transition event notification is a MinIO extension.
## Explore Further
- [MinIO | Golang Client API Reference](https://docs.min.io/docs/golang-client-api-reference.html#SetBucketLifecycle)
- [Object Lifecycle Management](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html)

@ -55,6 +55,9 @@ const (
ObjectRestorePostInitiated
ObjectRestorePostCompleted
ObjectRestorePostAll
ObjectTransitionAll
ObjectTransitionFailed
ObjectTransitionComplete
)
// Expand - returns expanded values of abbreviated event type.
@ -94,6 +97,11 @@ func (name Name) Expand() []Name {
ObjectRestorePostInitiated,
ObjectRestorePostCompleted,
}
case ObjectTransitionAll:
return []Name{
ObjectTransitionFailed,
ObjectTransitionComplete,
}
default:
return []Name{name}
}
@ -152,6 +160,12 @@ func (name Name) String() string {
return "s3:ObjectRestore:Post"
case ObjectRestorePostCompleted:
return "s3:ObjectRestore:Completed"
case ObjectTransitionAll:
return "s3:ObjectTransition:*"
case ObjectTransitionFailed:
return "s3:ObjectTransition:Failed"
case ObjectTransitionComplete:
return "s3:ObjectTransition:Complete"
}
return ""
@ -254,7 +268,12 @@ func ParseName(s string) (Name, error) {
return ObjectRestorePostInitiated, nil
case "s3:ObjectRestore:Completed":
return ObjectRestorePostCompleted, nil
case "s3:ObjectTransition:Failed":
return ObjectTransitionFailed, nil
case "s3:ObjectTransition:Complete":
return ObjectTransitionComplete, nil
case "s3:ObjectTransition:*":
return ObjectTransitionAll, nil
default:
return 0, &ErrInvalidEventName{s}
}

Loading…
Cancel
Save