Skip versions expired by DeleteAllVersionsAction (#18537)

Object versions expired by DeleteAllVersionsAction must not be included
toward data-usage accounting.
This commit is contained in:
Krishnan Parthasarathi
2023-11-28 08:39:21 -08:00
committed by GitHub
parent b0264bdb90
commit 9fbd931058
3 changed files with 51 additions and 18 deletions

View File

@@ -567,11 +567,19 @@ func (s *xlStorage) NSScanner(ctx context.Context, cache dataUsageCache, updates
versioned := vcfg != nil && vcfg.Versioned(item.objectPath())
var objDeleted bool
for _, oi := range objInfos {
done = globalScannerMetrics.time(scannerMetricApplyVersion)
sz := item.applyActions(ctx, objAPI, oi, &sizeS)
var sz int64
objDeleted, sz = item.applyActions(ctx, objAPI, oi, &sizeS)
done()
// DeleteAllVersionsAction: The object and all its
// versions are expired and
// doesn't contribute toward data usage.
if objDeleted {
break
}
actualSz, err := oi.GetActualSize()
if err != nil {
continue
@@ -644,6 +652,12 @@ func (s *xlStorage) NSScanner(ctx context.Context, cache dataUsageCache, updates
}
}
}
if objDeleted {
// we return errIgnoreFileContrib to signal this function's
// callers to skip this object's contribution towards
// usage.
return sizeSummary{}, errIgnoreFileContrib
}
return sizeS, nil
}, scanMode)
if err != nil {