From 0dadfd1b3df782be1a95476e34ddafaa57d2dbbf Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 17 Jan 2021 13:58:41 -0800 Subject: [PATCH] fix: do not compute usage for not found lifecycle operations (#11288) Currently we would proceed to apply incorrect lifecycle policies for non-existent objects, this PR handles them appropriately. --- cmd/data-crawler.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/data-crawler.go b/cmd/data-crawler.go index 05cbd8ec1..8d07135cf 100644 --- a/cmd/data-crawler.go +++ b/cmd/data-crawler.go @@ -863,8 +863,8 @@ func (i *crawlItem) applyActions(ctx context.Context, o ObjectLayer, meta action logger.LogIf(ctx, err) return size } - case ObjectNotFound: - // object not found return 0 + case ObjectNotFound, VersionNotFound: + // object not found or version not found return 0 return 0 default: // All other errors proceed. @@ -930,6 +930,9 @@ func (i *crawlItem) applyActions(ctx context.Context, o ObjectLayer, meta action opts.VersionID = obj.VersionID opts.TransitionStatus = lifecycle.TransitionPending if _, err = o.DeleteObject(ctx, obj.Bucket, obj.Name, opts); err != nil { + if isErrObjectNotFound(err) || isErrVersionNotFound(err) { + return 0 + } // Assume it is still there. logger.LogIf(ctx, err) return size @@ -941,6 +944,9 @@ func (i *crawlItem) applyActions(ctx context.Context, o ObjectLayer, meta action if obj.TransitionStatus != "" { if err := deleteTransitionedObject(ctx, o, i.bucket, i.objectPath(), lcOpts, action, false); err != nil { + if isErrObjectNotFound(err) || isErrVersionNotFound(err) { + return 0 + } logger.LogIf(ctx, err) return size } @@ -950,6 +956,9 @@ func (i *crawlItem) applyActions(ctx context.Context, o ObjectLayer, meta action obj, err = o.DeleteObject(ctx, i.bucket, i.objectPath(), opts) if err != nil { + if isErrObjectNotFound(err) || isErrVersionNotFound(err) { + return 0 + } // Assume it is still there. logger.LogIf(ctx, err) return size