[#4] Don't check tags for multiparts

Spec https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-configuration-examples.html#lc-expire-mpu
says: "When you use the AbortIncompleteMultipartUpload S3
 Lifecycle action, the rule cannot specify a tag-based filter."

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2024-07-26 14:57:37 +03:00
parent 15c9d55b03
commit 2613504b94

View file

@ -156,10 +156,7 @@ func (e *Executor) worker(ctx context.Context, job Job) error {
return nil return nil
} }
const ( const creationEpochKV = "CreationEpoch"
creationEpochKV = "CreationEpoch"
tagPrefix = "S3-Tag-"
)
func (e *Executor) abortMultiparts(ctx context.Context, ni *netmap.NetworkInfo, rules []data.LifecycleRule, bktInfo *data.BucketInfo) error { func (e *Executor) abortMultiparts(ctx context.Context, ni *netmap.NetworkInfo, rules []data.LifecycleRule, bktInfo *data.BucketInfo) error {
if len(rules) == 0 { if len(rules) == 0 {
@ -244,10 +241,6 @@ func (e *Executor) matchMultipartByRuleFn(ni *netmap.NetworkInfo, rule data.Life
if filter.And != nil { if filter.And != nil {
prefix = filter.And.Prefix prefix = filter.And.Prefix
} }
if filter.Tag != nil || filter.And != nil {
matchMultipartByTags = matchMultipartByTagsFunc(filter)
}
} }
return func(multipart *data.MultipartInfo) bool { return func(multipart *data.MultipartInfo) bool {
@ -670,33 +663,6 @@ func versionCreationEpoch(version *data.NodeVersion, ni *netmap.NetworkInfo) (ui
return objCreationEpoch, nil return objCreationEpoch, nil
} }
func matchMultipartByTagsFunc(filter *data.LifecycleRuleFilter) func(*data.MultipartInfo) bool {
return func(info *data.MultipartInfo) bool {
tags := make(map[string]string)
for k, v := range info.Meta {
if strings.HasPrefix(k, tagPrefix) {
tags[k[len(tagPrefix):]] = v
}
}
if filter.Tag != nil {
if tags[filter.Tag.Key] != filter.Tag.Value {
return false
}
}
if filter.And != nil {
for _, tag := range filter.And.Tags {
if tags[tag.Key] != tag.Value {
return false
}
}
}
return true
}
}
func (e *Executor) abortMultipart(ctx context.Context, bktInfo *data.BucketInfo, multipart *data.MultipartInfo) error { func (e *Executor) abortMultipart(ctx context.Context, bktInfo *data.BucketInfo, multipart *data.MultipartInfo) error {
parts, err := e.tree.GetParts(ctx, bktInfo, multipart.ID) parts, err := e.tree.GetParts(ctx, bktInfo, multipart.ID)
if err != nil { if err != nil {