mirror of
https://github.com/minio/minio.git
synced 2024-12-26 23:25:54 -05:00
avoid decommissioning DEL markers with single versions (#17274)
This commit is contained in:
parent
d749aaab69
commit
9b5829c16e
@ -673,9 +673,6 @@ func (z *erasureServerPools) decommissionPool(ctx context.Context, idx int, pool
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, set := range pool.sets {
|
|
||||||
set := set
|
|
||||||
|
|
||||||
vc, _ := globalBucketVersioningSys.Get(bi.Name)
|
vc, _ := globalBucketVersioningSys.Get(bi.Name)
|
||||||
|
|
||||||
// Check if the current bucket has a configured lifecycle policy
|
// Check if the current bucket has a configured lifecycle policy
|
||||||
@ -684,6 +681,9 @@ func (z *erasureServerPools) decommissionPool(ctx context.Context, idx int, pool
|
|||||||
// Check if bucket is object locked.
|
// Check if bucket is object locked.
|
||||||
lr, _ := globalBucketObjectLockSys.Get(bi.Name)
|
lr, _ := globalBucketObjectLockSys.Get(bi.Name)
|
||||||
|
|
||||||
|
for _, set := range pool.sets {
|
||||||
|
set := set
|
||||||
|
|
||||||
filterLifecycle := func(bucket, object string, fi FileInfo) bool {
|
filterLifecycle := func(bucket, object string, fi FileInfo) bool {
|
||||||
if lc == nil {
|
if lc == nil {
|
||||||
return false
|
return false
|
||||||
@ -728,22 +728,33 @@ func (z *erasureServerPools) decommissionPool(ctx context.Context, idx int, pool
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// any object with only single DEL marker we don't need
|
||||||
|
// to decommission, just skip it.
|
||||||
|
if version.Deleted && len(fivs.Versions) == 1 {
|
||||||
|
decommissionedCount++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
versionID := version.VersionID
|
||||||
|
if versionID == "" {
|
||||||
|
versionID = nullVersionID
|
||||||
|
}
|
||||||
|
|
||||||
if version.Deleted {
|
if version.Deleted {
|
||||||
_, err := z.DeleteObject(ctx,
|
_, err := z.DeleteObject(ctx,
|
||||||
bi.Name,
|
bi.Name,
|
||||||
version.Name,
|
version.Name,
|
||||||
ObjectOptions{
|
ObjectOptions{
|
||||||
Versioned: vc.PrefixEnabled(version.Name),
|
// Since we are preserving a delete marker, we have to make sure this is always true.
|
||||||
VersionID: version.VersionID,
|
// regardless of the current configuration of the bucket we must preserve all versions
|
||||||
|
// on the pool being decommissioned.
|
||||||
|
Versioned: true,
|
||||||
|
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
|
||||||
SkipDecommissioned: true, // make sure we skip the decommissioned pool
|
SkipDecommissioned: true, // make sure we skip the decommissioned pool
|
||||||
})
|
})
|
||||||
if isErrObjectNotFound(err) || isErrVersionNotFound(err) {
|
|
||||||
// object/version already deleted by the application, nothing to do here we move on.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var failure bool
|
var failure bool
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
@ -765,7 +776,7 @@ func (z *erasureServerPools) decommissionPool(ctx context.Context, idx int, pool
|
|||||||
if version.IsRemote() {
|
if version.IsRemote() {
|
||||||
stopFn := globalDecommissionMetrics.log(decomMetricDecommissionObject, idx, bi.Name, version.Name, version.VersionID)
|
stopFn := globalDecommissionMetrics.log(decomMetricDecommissionObject, idx, bi.Name, version.Name, version.VersionID)
|
||||||
if err := z.DecomTieredObject(ctx, bi.Name, version.Name, version, ObjectOptions{
|
if err := z.DecomTieredObject(ctx, bi.Name, version.Name, version, ObjectOptions{
|
||||||
VersionID: version.VersionID,
|
VersionID: versionID,
|
||||||
MTime: version.ModTime,
|
MTime: version.ModTime,
|
||||||
UserDefined: version.Metadata,
|
UserDefined: version.Metadata,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -785,7 +796,7 @@ func (z *erasureServerPools) decommissionPool(ctx context.Context, idx int, pool
|
|||||||
nil,
|
nil,
|
||||||
http.Header{},
|
http.Header{},
|
||||||
ObjectOptions{
|
ObjectOptions{
|
||||||
VersionID: version.VersionID,
|
VersionID: versionID,
|
||||||
NoDecryption: true,
|
NoDecryption: true,
|
||||||
NoLock: true,
|
NoLock: true,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user