lc: Apply DeleteAction correctly to objects (#11471)

When lifecycle decides to Delete an object and not a version in a
versioned bucket, the code should create a delete marker and not
removing the scanned version.

This commit fixes the issue.
This commit is contained in:
Anis Elleuch
2021-02-07 01:10:33 +01:00
committed by GitHub
parent 97fe57bba9
commit 275f7a63e8
3 changed files with 22 additions and 15 deletions

View File

@@ -65,13 +65,18 @@ func NewLifecycleSys() *LifecycleSys {
return &LifecycleSys{}
}
type expiryState struct {
expiryCh chan ObjectInfo
type expiryTask struct {
objInfo ObjectInfo
versionExpiry bool
}
func (es *expiryState) queueExpiryTask(oi ObjectInfo) {
type expiryState struct {
expiryCh chan expiryTask
}
func (es *expiryState) queueExpiryTask(oi ObjectInfo, rmVersion bool) {
select {
case es.expiryCh <- oi:
case es.expiryCh <- expiryTask{objInfo: oi, versionExpiry: rmVersion}:
default:
}
}
@@ -82,7 +87,7 @@ var (
func newExpiryState() *expiryState {
es := &expiryState{
expiryCh: make(chan ObjectInfo, 10000),
expiryCh: make(chan expiryTask, 10000),
}
go func() {
<-GlobalContext.Done()
@@ -94,8 +99,8 @@ func newExpiryState() *expiryState {
func initBackgroundExpiry(ctx context.Context, objectAPI ObjectLayer) {
globalExpiryState = newExpiryState()
go func() {
for oi := range globalExpiryState.expiryCh {
applyExpiryRule(ctx, objectAPI, oi, false)
for t := range globalExpiryState.expiryCh {
applyExpiryRule(ctx, objectAPI, t.objInfo, false, t.versionExpiry)
}
}()
}