From d21b6daa491d523e22e6e70d42c6bc56f2d3fc43 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 11 Jun 2024 06:50:53 -0700 Subject: [PATCH] fix: avoid crash when delete() returns an error in batch expiration (#19909) --- cmd/batch-expire.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/batch-expire.go b/cmd/batch-expire.go index cd20cf2c2..1e137ed78 100644 --- a/cmd/batch-expire.go +++ b/cmd/batch-expire.go @@ -432,7 +432,7 @@ func batchObjsForDelete(ctx context.Context, r *BatchJobExpire, ri *batchJobInfo }) if err != nil { stopFn(exp, err) - batchLogIf(ctx, fmt.Errorf("Failed to expire %s/%s versionID=%s due to %v (attempts=%d)", toExpire[i].Bucket, toExpire[i].Name, toExpire[i].VersionID, err, attempts)) + batchLogIf(ctx, fmt.Errorf("Failed to expire %s/%s due to %v (attempts=%d)", exp.Bucket, exp.Name, err, attempts)) } else { stopFn(exp, err) success = true @@ -464,13 +464,13 @@ func batchObjsForDelete(ctx context.Context, r *BatchJobExpire, ri *batchJobInfo copy(toDelCopy, toDel) var failed int errs := r.Expire(ctx, api, vc, toDel) - // reslice toDel in preparation for next retry - // attempt + // reslice toDel in preparation for next retry attempt toDel = toDel[:0] for i, err := range errs { if err != nil { stopFn(toDelCopy[i], err) - batchLogIf(ctx, fmt.Errorf("Failed to expire %s/%s versionID=%s due to %v (attempts=%d)", ri.Bucket, toDelCopy[i].ObjectName, toDelCopy[i].VersionID, err, attempts)) + batchLogIf(ctx, fmt.Errorf("Failed to expire %s/%s versionID=%s due to %v (attempts=%d)", ri.Bucket, toDelCopy[i].ObjectName, toDelCopy[i].VersionID, + err, attempts)) failed++ if oi, ok := oiCache.Get(toDelCopy[i]); ok { ri.trackCurrentBucketObject(r.Bucket, *oi, false, attempts)