count all versions as part of DeleteAllVersionsAction (#17821)

This commit is contained in:
Harshavardhana 2023-08-09 08:55:19 -07:00 committed by GitHub
parent b732a673dc
commit 6e860b6dc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View File

@ -142,14 +142,14 @@ func (p *scannerMetrics) incTime(s scannerMetric, d time.Duration) {
// timeILM times an ILM action. // timeILM times an ILM action.
// lifecycle.NoneAction is ignored. // lifecycle.NoneAction is ignored.
// Use for s < scannerMetricLastRealtime // Use for s < scannerMetricLastRealtime
func (p *scannerMetrics) timeILM(a lifecycle.Action) func() { func (p *scannerMetrics) timeILM(a lifecycle.Action) func(versions uint64) {
if a == lifecycle.NoneAction || a >= lifecycle.ActionCount { if a == lifecycle.NoneAction || a >= lifecycle.ActionCount {
return func() {} return func(_ uint64) {}
} }
startTime := time.Now() startTime := time.Now()
return func() { return func(versions uint64) {
duration := time.Since(startTime) duration := time.Since(startTime)
atomic.AddUint64(&p.actions[a], 1) atomic.AddUint64(&p.actions[a], versions)
p.actionsLatency[a].add(duration) p.actionsLatency[a].add(duration)
} }
} }

View File

@ -930,7 +930,15 @@ func (i *scannerItem) applyLifecycle(ctx context.Context, o ObjectLayer, oi Obje
console.Debugf(applyActionsLogPrefix+" lifecycle: %q Initial scan: %v\n", i.objectPath(), lcEvt.Action) console.Debugf(applyActionsLogPrefix+" lifecycle: %q Initial scan: %v\n", i.objectPath(), lcEvt.Action)
} }
} }
defer globalScannerMetrics.timeILM(lcEvt.Action)() defer func() {
if applied {
numVersions := uint64(1)
if lcEvt.Action == lifecycle.DeleteAllVersionsAction {
numVersions = uint64(oi.NumVersions)
}
globalScannerMetrics.timeILM(lcEvt.Action)(numVersions)
}
}()
switch lcEvt.Action { switch lcEvt.Action {
case lifecycle.DeleteAction, lifecycle.DeleteVersionAction, lifecycle.DeleteRestoredAction, lifecycle.DeleteRestoredVersionAction, lifecycle.DeleteAllVersionsAction: case lifecycle.DeleteAction, lifecycle.DeleteVersionAction, lifecycle.DeleteRestoredAction, lifecycle.DeleteRestoredVersionAction, lifecycle.DeleteAllVersionsAction:

View File

@ -558,8 +558,13 @@ func (s *xlStorage) NSScanner(ctx context.Context, cache dataUsageCache, updates
for _, oi := range objInfos { for _, oi := range objInfos {
done = globalScannerMetrics.time(scannerMetricApplyVersion) done = globalScannerMetrics.time(scannerMetricApplyVersion)
sz := item.applyActions(ctx, objAPI, oi, &sizeS) sz := item.applyActions(ctx, objAPI, oi, &sizeS)
actualSz, _ := oi.GetActualSize()
done() done()
actualSz, err := oi.GetActualSize()
if err != nil {
continue
}
if oi.DeleteMarker { if oi.DeleteMarker {
sizeS.deleteMarkers++ sizeS.deleteMarkers++
} }