mirror of
https://github.com/minio/minio.git
synced 2025-11-22 02:35:30 -05:00
feat: allow expiration of all versions via ILM Expiration action (#17521)
Following extension allows users to specify immediate purge of
all versions as soon as the latest version of this object has
expired.
```
<LifecycleConfiguration>
<Rule>
<ID>ClassADocRule</ID>
<Filter>
<Prefix>classA/</Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration>
<Days>3650</Days>
<ExpiredObjectAllVersions>true</ExpiredObjectAllVersions>
</Expiration>
</Rule>
...
```
This commit is contained in:
@@ -65,6 +65,8 @@ const (
|
||||
DeleteRestoredAction
|
||||
// DeleteRestoredVersionAction deletes a particular version that was temporarily restored
|
||||
DeleteRestoredVersionAction
|
||||
// DeleteAllVersionsAction deletes all versions when an object expires
|
||||
DeleteAllVersionsAction
|
||||
|
||||
// ActionCount must be the last action and shouldn't be used as a regular action.
|
||||
ActionCount
|
||||
@@ -80,6 +82,11 @@ func (a Action) DeleteVersioned() bool {
|
||||
return a == DeleteVersionAction || a == DeleteRestoredVersionAction
|
||||
}
|
||||
|
||||
// DeleteAll - Returns true if the action demands deleting all versions of an object
|
||||
func (a Action) DeleteAll() bool {
|
||||
return a == DeleteAllVersionsAction
|
||||
}
|
||||
|
||||
// Delete - Returns true if action demands delete on all objects (including restored)
|
||||
func (a Action) Delete() bool {
|
||||
if a.DeleteRestored() {
|
||||
@@ -324,6 +331,23 @@ func (lc Lifecycle) eval(obj ObjectOpts, now time.Time) Event {
|
||||
}
|
||||
|
||||
for _, rule := range lc.FilterRules(obj) {
|
||||
if obj.IsLatest && rule.Expiration.DeleteAll.val {
|
||||
if !rule.Expiration.IsDaysNull() {
|
||||
// Specifying the Days tag will automatically perform all versions cleanup
|
||||
// once the latest object is old enough to satisfy the age criteria.
|
||||
// This is a MinIO only extension.
|
||||
if expectedExpiry := ExpectedExpiryTime(obj.ModTime, int(rule.Expiration.Days)); now.IsZero() || now.After(expectedExpiry) {
|
||||
events = append(events, Event{
|
||||
Action: DeleteAllVersionsAction,
|
||||
RuleID: rule.ID,
|
||||
Due: expectedExpiry,
|
||||
})
|
||||
// No other conflicting actions apply to an all version expired object.
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if obj.ExpiredObjectDeleteMarker() {
|
||||
if rule.Expiration.DeleteMarker.val {
|
||||
// Indicates whether MinIO will remove a delete marker with no noncurrent versions.
|
||||
|
||||
Reference in New Issue
Block a user