From bbf3576f70390309c4ff73f7f15a20223b383764 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 24 Aug 2021 12:24:00 -0700 Subject: [PATCH] remove unecessary metadata structs in applyTransitionAction() (#13059) --- cmd/bucket-lifecycle.go | 7 ++++--- cmd/data-scanner.go | 22 +++++++--------------- cmd/erasure-object.go | 4 +++- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/cmd/bucket-lifecycle.go b/cmd/bucket-lifecycle.go index 29d60d659..8a5d84af1 100644 --- a/cmd/bucket-lifecycle.go +++ b/cmd/bucket-lifecycle.go @@ -327,9 +327,10 @@ func transitionObject(ctx context.Context, objectAPI ObjectLayer, oi ObjectInfo) Tier: lc.TransitionTier(oi.ToLifecycleOpts()), ETag: oi.ETag, }, - VersionID: oi.VersionID, - Versioned: globalBucketVersioningSys.Enabled(oi.Bucket), - MTime: oi.ModTime, + VersionID: oi.VersionID, + Versioned: globalBucketVersioningSys.Enabled(oi.Bucket), + VersionSuspended: globalBucketVersioningSys.Suspended(oi.Bucket), + MTime: oi.ModTime, } return objectAPI.TransitionObject(ctx, oi.Bucket, oi.Name, opts) } diff --git a/cmd/data-scanner.go b/cmd/data-scanner.go index a579d1947..79eb81439 100644 --- a/cmd/data-scanner.go +++ b/cmd/data-scanner.go @@ -996,9 +996,9 @@ func (i *scannerItem) applyTierObjSweep(ctx context.Context, o ObjectLayer, meta } // Remove this free version - opts := ObjectOptions{} - opts.VersionID = meta.oi.VersionID - _, err = o.DeleteObject(ctx, meta.oi.Bucket, meta.oi.Name, opts) + _, err = o.DeleteObject(ctx, meta.oi.Bucket, meta.oi.Name, ObjectOptions{ + VersionID: meta.oi.VersionID, + }) if err == nil { auditLogLifecycle(ctx, meta.oi, ILMFreeVersionDelete) } @@ -1063,17 +1063,9 @@ func evalActionFromLifecycle(ctx context.Context, lc lifecycle.Lifecycle, obj Ob return action } -func applyTransitionAction(ctx context.Context, action lifecycle.Action, objLayer ObjectLayer, obj ObjectInfo) bool { - srcOpts := ObjectOptions{} - if obj.TransitionedObject.Status == "" { - srcOpts.Versioned = globalBucketVersioningSys.Enabled(obj.Bucket) - srcOpts.VersionID = obj.VersionID - // mark transition as pending - obj.UserDefined[ReservedMetadataPrefixLower+TransitionStatus] = lifecycle.TransitionPending - obj.metadataOnly = true // Perform only metadata updates. - if obj.DeleteMarker { - return false - } +func applyTransitionRule(ctx context.Context, action lifecycle.Action, objLayer ObjectLayer, obj ObjectInfo) bool { + if obj.DeleteMarker { + return false } globalTransitionState.queueTransitionTask(obj) return true @@ -1151,7 +1143,7 @@ func applyLifecycleAction(ctx context.Context, action lifecycle.Action, objLayer case lifecycle.DeleteRestoredAction, lifecycle.DeleteRestoredVersionAction: success = applyExpiryRule(ctx, objLayer, obj, true, action == lifecycle.DeleteRestoredVersionAction) case lifecycle.TransitionAction, lifecycle.TransitionVersionAction: - success = applyTransitionAction(ctx, action, objLayer, obj) + success = applyTransitionRule(ctx, action, objLayer, obj) } return } diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index 6d06b91da..0b4fec875 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -1476,7 +1476,6 @@ func (er erasureObjects) TransitionObject(ctx context.Context, bucket, object st if err != nil { return err } - defer NSUpdated(bucket, object) // Acquire write lock before starting to transition the object. lk := er.NewNSLock(bucket, object) @@ -1506,6 +1505,8 @@ func (er erasureObjects) TransitionObject(ctx context.Context, bucket, object st if fi.TransitionStatus == lifecycle.TransitionComplete { return nil } + defer NSUpdated(bucket, object) + if fi.XLV1 { if _, err = er.HealObject(ctx, bucket, object, "", madmin.HealOpts{NoLock: true}); err != nil { return err @@ -1548,6 +1549,7 @@ func (er erasureObjects) TransitionObject(ctx context.Context, bucket, object st if err = er.deleteObjectVersion(ctx, bucket, object, writeQuorum, fi, false); err != nil { eventName = event.ObjectTransitionFailed } + for _, disk := range storageDisks { if disk != nil && disk.IsOnline() { continue