mirror of
https://github.com/minio/minio.git
synced 2025-05-21 17:43:48 -04:00
fix ILM should not remove a protected version (#10189)
This commit is contained in:
parent
b16781846e
commit
6ae30b21c9
@ -510,7 +510,6 @@ func (i *crawlItem) transformMetaDir() {
|
|||||||
// actionMeta contains information used to apply actions.
|
// actionMeta contains information used to apply actions.
|
||||||
type actionMeta struct {
|
type actionMeta struct {
|
||||||
oi ObjectInfo
|
oi ObjectInfo
|
||||||
trustOI bool // Set true if oi can be trusted and has been read with quorum.
|
|
||||||
numVersions int // The number of versions of this object
|
numVersions int // The number of versions of this object
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +538,7 @@ func (i *crawlItem) applyActions(ctx context.Context, o ObjectLayer, meta action
|
|||||||
NumVersions: meta.numVersions,
|
NumVersions: meta.numVersions,
|
||||||
})
|
})
|
||||||
if i.debug {
|
if i.debug {
|
||||||
logger.Info(color.Green("applyActions:")+" lifecycle: %q, Initial scan: %v", i.objectPath(), action)
|
logger.Info(color.Green("applyActions:")+" lifecycle: %q (version-id=%s), Initial scan: %v", i.objectPath(), versionID, action)
|
||||||
}
|
}
|
||||||
switch action {
|
switch action {
|
||||||
case lifecycle.DeleteAction, lifecycle.DeleteVersionAction:
|
case lifecycle.DeleteAction, lifecycle.DeleteVersionAction:
|
||||||
@ -548,9 +547,6 @@ func (i *crawlItem) applyActions(ctx context.Context, o ObjectLayer, meta action
|
|||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
// These (expensive) operations should only run on items we are likely to delete.
|
|
||||||
// Load to ensure that we have the correct version and not an unsynced version.
|
|
||||||
if !meta.trustOI {
|
|
||||||
obj, err := o.GetObjectInfo(ctx, i.bucket, i.objectPath(), ObjectOptions{
|
obj, err := o.GetObjectInfo(ctx, i.bucket, i.objectPath(), ObjectOptions{
|
||||||
VersionID: versionID,
|
VersionID: versionID,
|
||||||
})
|
})
|
||||||
@ -587,24 +583,35 @@ func (i *crawlItem) applyActions(ctx context.Context, o ObjectLayer, meta action
|
|||||||
if i.debug {
|
if i.debug {
|
||||||
logger.Info(color.Green("applyActions:")+" lifecycle: Secondary scan: %v", action)
|
logger.Info(color.Green("applyActions:")+" lifecycle: Secondary scan: %v", action)
|
||||||
}
|
}
|
||||||
versionID = obj.VersionID
|
|
||||||
switch action {
|
switch action {
|
||||||
case lifecycle.DeleteAction, lifecycle.DeleteVersionAction:
|
case lifecycle.DeleteAction, lifecycle.DeleteVersionAction:
|
||||||
default:
|
default:
|
||||||
// No action.
|
// No action.
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
opts := ObjectOptions{}
|
opts := ObjectOptions{}
|
||||||
switch action {
|
switch action {
|
||||||
case lifecycle.DeleteVersionAction:
|
case lifecycle.DeleteVersionAction:
|
||||||
opts.VersionID = versionID
|
// Defensive code, should never happen
|
||||||
|
if obj.VersionID == "" {
|
||||||
|
return size
|
||||||
|
}
|
||||||
|
if rcfg, _ := globalBucketObjectLockSys.Get(i.bucket); rcfg.LockEnabled {
|
||||||
|
locked := enforceRetentionForDeletion(ctx, obj)
|
||||||
|
if locked {
|
||||||
|
if i.debug {
|
||||||
|
logger.Info(color.Green("applyActions:")+" lifecycle: %s is locked, not deleting", i.objectPath())
|
||||||
|
}
|
||||||
|
return size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
opts.VersionID = obj.VersionID
|
||||||
case lifecycle.DeleteAction:
|
case lifecycle.DeleteAction:
|
||||||
opts.Versioned = globalBucketVersioningSys.Enabled(i.bucket)
|
opts.Versioned = globalBucketVersioningSys.Enabled(i.bucket)
|
||||||
}
|
}
|
||||||
|
|
||||||
obj, err := o.DeleteObject(ctx, i.bucket, i.objectPath(), opts)
|
obj, err = o.DeleteObject(ctx, i.bucket, i.objectPath(), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Assume it is still there.
|
// Assume it is still there.
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user