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.
master
Harshavardhana 4 years ago committed by GitHub
parent 98f76008c7
commit 0dadfd1b3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      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

Loading…
Cancel
Save