rebalance 'null' delete markers properly (#17282)

This commit is contained in:
Harshavardhana 2023-05-25 16:12:53 -07:00 committed by GitHub
parent 54c5c88fe6
commit 5cd9dcb844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -506,25 +506,29 @@ func (z *erasureServerPools) rebalanceBucket(ctx context.Context, bucket string,
// Apply lifecycle rules on the objects that are expired. // Apply lifecycle rules on the objects that are expired.
if filterLifecycle(bucket, version.Name, version) { 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 continue
} }
// We will skip rebalancing delete markers // Empty delete markers we can assume that they can be purged
// with single version, its as good as there // as there is no more data associated with them.
// is no data associated with the object.
if version.Deleted && len(fivs.Versions) == 1 { 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 continue
} }
versionID := version.VersionID
if versionID == "" {
versionID = nullVersionID
}
if version.Deleted { if version.Deleted {
_, err := z.DeleteObject(ctx, _, err := z.DeleteObject(ctx,
bucket, bucket,
version.Name, version.Name,
ObjectOptions{ ObjectOptions{
Versioned: vc.PrefixEnabled(version.Name), Versioned: true,
VersionID: version.VersionID, VersionID: versionID,
MTime: version.ModTime, MTime: version.ModTime,
DeleteReplication: version.ReplicationState, DeleteReplication: version.ReplicationState,
DeleteMarker: true, // make sure we create a delete marker DeleteMarker: true, // make sure we create a delete marker
@ -552,7 +556,7 @@ func (z *erasureServerPools) rebalanceBucket(ctx context.Context, bucket string,
nil, nil,
http.Header{}, http.Header{},
ObjectOptions{ ObjectOptions{
VersionID: version.VersionID, VersionID: versionID,
NoDecryption: true, NoDecryption: true,
NoLock: true, NoLock: true,
}) })