mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
enforceRetentionForDeletion should return false early for delete-marker (#14033)
This commit is contained in:
parent
557135185c
commit
89441a22aa
@ -58,6 +58,10 @@ func (sys *BucketObjectLockSys) Get(bucketName string) (r objectlock.Retention,
|
|||||||
// enforceRetentionForDeletion checks if it is appropriate to remove an
|
// enforceRetentionForDeletion checks if it is appropriate to remove an
|
||||||
// object according to locking configuration when this is lifecycle/ bucket quota asking.
|
// object according to locking configuration when this is lifecycle/ bucket quota asking.
|
||||||
func enforceRetentionForDeletion(ctx context.Context, objInfo ObjectInfo) (locked bool) {
|
func enforceRetentionForDeletion(ctx context.Context, objInfo ObjectInfo) (locked bool) {
|
||||||
|
if objInfo.DeleteMarker {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
lhold := objectlock.GetObjectLegalHoldMeta(objInfo.UserDefined)
|
lhold := objectlock.GetObjectLegalHoldMeta(objInfo.UserDefined)
|
||||||
if lhold.Status.Valid() && lhold.Status == objectlock.LegalHoldOn {
|
if lhold.Status.Valid() && lhold.Status == objectlock.LegalHoldOn {
|
||||||
return true
|
return true
|
||||||
|
@ -154,7 +154,7 @@ func enforceFIFOQuotaBucket(ctx context.Context, objectAPI ObjectLayer, bucket s
|
|||||||
// ModTime to find the oldest objects in bucket to delete. In
|
// ModTime to find the oldest objects in bucket to delete. In
|
||||||
// the context of bucket quota enforcement - number of hits are
|
// the context of bucket quota enforcement - number of hits are
|
||||||
// irrelevant.
|
// irrelevant.
|
||||||
scorer, err := newFileScorer(toFree, time.Now().Unix(), 1)
|
scorer, err := newFileScorer(toFree, UTCNow().Unix(), 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
return
|
return
|
||||||
@ -162,11 +162,6 @@ func enforceFIFOQuotaBucket(ctx context.Context, objectAPI ObjectLayer, bucket s
|
|||||||
|
|
||||||
rcfg, _ := globalBucketObjectLockSys.Get(bucket)
|
rcfg, _ := globalBucketObjectLockSys.Get(bucket)
|
||||||
for obj := range objInfoCh {
|
for obj := range objInfoCh {
|
||||||
if obj.DeleteMarker {
|
|
||||||
// Delete markers are automatically added for FIFO purge.
|
|
||||||
scorer.addFileWithObjInfo(obj, 1)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// skip objects currently under retention
|
// skip objects currently under retention
|
||||||
if rcfg.LockEnabled && enforceRetentionForDeletion(ctx, obj) {
|
if rcfg.LockEnabled && enforceRetentionForDeletion(ctx, obj) {
|
||||||
continue
|
continue
|
||||||
@ -178,6 +173,7 @@ func enforceFIFOQuotaBucket(ctx context.Context, objectAPI ObjectLayer, bucket s
|
|||||||
if scorer.seenBytes <= cfg.Quota {
|
if scorer.seenBytes <= cfg.Quota {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate how much we want to delete now.
|
// Calculate how much we want to delete now.
|
||||||
toFreeNow := scorer.seenBytes - cfg.Quota
|
toFreeNow := scorer.seenBytes - cfg.Quota
|
||||||
// We were less over quota than we thought. Adjust so we delete less.
|
// We were less over quota than we thought. Adjust so we delete less.
|
||||||
@ -211,9 +207,9 @@ func enforceFIFOQuotaBucket(ctx context.Context, objectAPI ObjectLayer, bucket s
|
|||||||
_, deleteErrs := objectAPI.DeleteObjects(ctx, bucket, objects, ObjectOptions{
|
_, deleteErrs := objectAPI.DeleteObjects(ctx, bucket, objects, ObjectOptions{
|
||||||
Versioned: versioned,
|
Versioned: versioned,
|
||||||
})
|
})
|
||||||
for i := range deleteErrs {
|
for j := range deleteErrs {
|
||||||
if deleteErrs[i] != nil {
|
if deleteErrs[j] != nil {
|
||||||
logger.LogIf(ctx, deleteErrs[i])
|
logger.LogIf(ctx, deleteErrs[j])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user