From 5cd9dcb844651bd953634baa0e89b9e6a9799697 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 25 May 2023 16:12:53 -0700 Subject: [PATCH] rebalance 'null' delete markers properly (#17282) --- cmd/erasure-server-pool-rebalance.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/erasure-server-pool-rebalance.go b/cmd/erasure-server-pool-rebalance.go index 9248855af..0e47116b3 100644 --- a/cmd/erasure-server-pool-rebalance.go +++ b/cmd/erasure-server-pool-rebalance.go @@ -506,25 +506,29 @@ func (z *erasureServerPools) rebalanceBucket(ctx context.Context, bucket string, // Apply lifecycle rules on the objects that are expired. if filterLifecycle(bucket, version.Name, version) { - logger.LogIf(ctx, fmt.Errorf("found %s/%s (%s) expired object based on ILM rules, skipping and scheduled for deletion", bucket, version.Name, version.VersionID)) + rebalanced++ continue } - // We will skip rebalancing delete markers - // with single version, its as good as there - // is no data associated with the object. + // Empty delete markers we can assume that they can be purged + // as there is no more data associated with them. if version.Deleted && len(fivs.Versions) == 1 { - logger.LogIf(ctx, fmt.Errorf("found %s/%s delete marked object with no other versions, skipping since there is no data to be rebalanced", bucket, version.Name)) + rebalanced++ continue } + versionID := version.VersionID + if versionID == "" { + versionID = nullVersionID + } + if version.Deleted { _, err := z.DeleteObject(ctx, bucket, version.Name, ObjectOptions{ - Versioned: vc.PrefixEnabled(version.Name), - VersionID: version.VersionID, + Versioned: true, + VersionID: versionID, MTime: version.ModTime, DeleteReplication: version.ReplicationState, DeleteMarker: true, // make sure we create a delete marker @@ -552,7 +556,7 @@ func (z *erasureServerPools) rebalanceBucket(ctx context.Context, bucket string, nil, http.Header{}, ObjectOptions{ - VersionID: version.VersionID, + VersionID: versionID, NoDecryption: true, NoLock: true, })