Disallow ExpiredObjectAllVersions with object lock (#19792)

Relaxes restrictions on Expiration and NoncurrentVersionExpiration
placed by https://github.com/minio/minio/pull/19785.
ref: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock-managing.html#object-lock-managing-lifecycle

> Object lifecycle management configurations continue functioning
normally on protected objects, including placing delete markers.
However, a locked version of an object cannot be deleted by a S3
Lifecycle expiration policy. Object Lock is maintained regardless of
the object's storage class and throughout S3 Lifecycle
transitions between storage classes.
This commit is contained in:
Krishnan Parthasarathi
2024-05-22 18:12:48 -07:00
committed by GitHub
parent d38e020b29
commit 6d5bc045bc
2 changed files with 27 additions and 16 deletions
+25 -11
View File
@@ -63,25 +63,39 @@ func TestParseAndValidateLifecycleConfig(t *testing.T) {
expectedParsingErr: nil,
expectedValidationErr: nil,
},
{ // invalid lifecycle config
{ // Using ExpiredObjectAllVersions element with an object locked bucket
inputConfig: `<LifecycleConfiguration>
<Rule>
<ID>testRule1</ID>
<Rule>
<ID>ExpiredObjectAllVersions with object locking</ID>
<Filter>
<Prefix>prefix</Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration><Days>3</Days></Expiration>
</Rule>
<Rule>
<ID>testRule2</ID>
<Expiration>
<Days>3</Days>
<ExpiredObjectAllVersions>true</ExpiredObjectAllVersions>
</Expiration>
</Rule>
</LifecycleConfiguration>`,
expectedParsingErr: nil,
expectedValidationErr: errLifecycleBucketLocked,
lr: lock.Retention{
LockEnabled: true,
},
},
{ // Using DelMarkerExpiration action with an object locked bucket
inputConfig: `<LifecycleConfiguration>
<Rule>
<ID>DeleteMarkerExpiration with object locking</ID>
<Filter>
<Prefix>another-prefix</Prefix>
<Prefix>prefix</Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration><Days>3</Days></Expiration>
</Rule>
</LifecycleConfiguration>`,
<DelMarkerExpiration>
<Days>3</Days>
</DelMarkerExpiration>
</Rule>
</LifecycleConfiguration>`,
expectedParsingErr: nil,
expectedValidationErr: errLifecycleBucketLocked,
lr: lock.Retention{