mirror of
https://github.com/minio/minio.git
synced 2025-04-20 02:27:50 -04:00
ilm: Expect objects with only free versions when scanning (#21112)
This commit is contained in:
parent
0bd8f06b62
commit
d0cada583f
@ -1036,6 +1036,9 @@ type actionsAccountingFn func(oi ObjectInfo, sz, actualSz int64, sizeS *sizeSumm
|
|||||||
// The metadata will be compared to consensus on the object layer before any changes are applied.
|
// The metadata will be compared to consensus on the object layer before any changes are applied.
|
||||||
// If no metadata is supplied, -1 is returned if no action is taken.
|
// If no metadata is supplied, -1 is returned if no action is taken.
|
||||||
func (i *scannerItem) applyActions(ctx context.Context, objAPI ObjectLayer, objInfos []ObjectInfo, lr lock.Retention, sizeS *sizeSummary, fn actionsAccountingFn) {
|
func (i *scannerItem) applyActions(ctx context.Context, objAPI ObjectLayer, objInfos []ObjectInfo, lr lock.Retention, sizeS *sizeSummary, fn actionsAccountingFn) {
|
||||||
|
if len(objInfos) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
healActions := func(oi ObjectInfo, actualSz int64) int64 {
|
healActions := func(oi ObjectInfo, actualSz int64) int64 {
|
||||||
size := actualSz
|
size := actualSz
|
||||||
if i.heal.enabled {
|
if i.heal.enabled {
|
||||||
|
@ -245,6 +245,12 @@ func TestApplyNewerNoncurrentVersionsLimit(t *testing.T) {
|
|||||||
wants: nil,
|
wants: nil,
|
||||||
wantExpired: []ObjectToDelete{{ObjectV: ObjectV{ObjectName: obj, VersionID: allVersExpObjInfos[0].VersionID}}},
|
wantExpired: []ObjectToDelete{{ObjectV: ObjectV{ObjectName: obj, VersionID: allVersExpObjInfos[0].VersionID}}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// When no versions are present, in practice this could be an object with only free versions
|
||||||
|
objInfos: nil,
|
||||||
|
wants: nil,
|
||||||
|
wantExpired: nil,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
t.Run(fmt.Sprintf("TestApplyNewerNoncurrentVersionsLimit-%d", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("TestApplyNewerNoncurrentVersionsLimit-%d", i), func(t *testing.T) {
|
||||||
|
@ -146,6 +146,9 @@ loop:
|
|||||||
|
|
||||||
// Eval will return a lifecycle event for each object in objs
|
// Eval will return a lifecycle event for each object in objs
|
||||||
func (e *Evaluator) Eval(objs []ObjectOpts) ([]Event, error) {
|
func (e *Evaluator) Eval(objs []ObjectOpts) ([]Event, error) {
|
||||||
|
if len(objs) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
if len(objs) != objs[0].NumVersions {
|
if len(objs) != objs[0].NumVersions {
|
||||||
return nil, fmt.Errorf("number of versions mismatch, expected %d, got %d", objs[0].NumVersions, len(objs))
|
return nil, fmt.Errorf("number of versions mismatch, expected %d, got %d", objs[0].NumVersions, len(objs))
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,12 @@ func TestNewerNoncurrentVersions(t *testing.T) {
|
|||||||
t.Fatalf("test-%d: got %v, want %v", i+1, gotEvents[i], wantEvents[i])
|
t.Fatalf("test-%d: got %v, want %v", i+1, gotEvents[i], wantEvents[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test with zero versions
|
||||||
|
events, err := evaluator.Eval(nil)
|
||||||
|
if len(events) != 0 || err != nil {
|
||||||
|
t.Fatal("expected no events nor error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEmptyEvaluator(t *testing.T) {
|
func TestEmptyEvaluator(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user