mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
ilm: Expire if object past expected expiry date (#19230)
When an object qualifies for both tiering and expiration rules and is past its expiration date, it should be expired without requiring to tier it, even when tiering event occurs before expiration.
This commit is contained in:
parent
31e8f7c525
commit
2007dd26ae
@ -471,9 +471,11 @@ func (lc Lifecycle) eval(obj ObjectOpts, now time.Time) Event {
|
||||
|
||||
if len(events) > 0 {
|
||||
sort.Slice(events, func(i, j int) bool {
|
||||
if events[i].Due.Equal(events[j].Due) {
|
||||
// Prefer Expiration over Transition for both current
|
||||
// and noncurrent versions
|
||||
// Prefer Expiration over Transition for both current
|
||||
// and noncurrent versions when,
|
||||
// - now is past the expected time to action
|
||||
// - expected time to action is the same for both actions
|
||||
if now.After(events[i].Due) && now.After(events[j].Due) || events[i].Due.Equal(events[j].Due) {
|
||||
switch events[i].Action {
|
||||
case DeleteAction, DeleteVersionAction:
|
||||
return true
|
||||
|
@ -539,6 +539,46 @@ func TestEval(t *testing.T) {
|
||||
objectModTime: time.Now().UTC().Add(-15 * 24 * time.Hour),
|
||||
expectedAction: DeleteAction,
|
||||
},
|
||||
{
|
||||
inputConfig: `<LifecycleConfiguration>
|
||||
<Rule>
|
||||
<ID>Rule 1</ID>
|
||||
<Status>Enabled</Status>
|
||||
<Filter></Filter>
|
||||
<Transition>
|
||||
<StorageClass>WARM-1</StorageClass>
|
||||
<Days>30</Days>
|
||||
</Transition>
|
||||
<Expiration>
|
||||
<Days>60</Days>
|
||||
</Expiration>
|
||||
</Rule>
|
||||
</LifecycleConfiguration>`,
|
||||
objectName: "obj-1",
|
||||
objectModTime: time.Now().UTC().Add(-90 * 24 * time.Hour),
|
||||
expectedAction: DeleteAction,
|
||||
},
|
||||
{
|
||||
inputConfig: `<LifecycleConfiguration>
|
||||
<Rule>
|
||||
<ID>Rule 2</ID>
|
||||
<Filter></Filter>
|
||||
<Status>Enabled</Status>
|
||||
<NoncurrentVersionExpiration>
|
||||
<NoncurrentDays>60</NoncurrentDays>
|
||||
</NoncurrentVersionExpiration>
|
||||
<NoncurrentVersionTransition>
|
||||
<StorageClass>WARM-1</StorageClass>
|
||||
<NoncurrentDays>30</NoncurrentDays>
|
||||
</NoncurrentVersionTransition>
|
||||
</Rule>
|
||||
</LifecycleConfiguration>`,
|
||||
objectName: "obj-1",
|
||||
isNoncurrent: true,
|
||||
objectModTime: time.Now().UTC().Add(-90 * 24 * time.Hour),
|
||||
objectSuccessorModTime: time.Now().UTC().Add(-90 * 24 * time.Hour),
|
||||
expectedAction: DeleteVersionAction,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
Loading…
Reference in New Issue
Block a user