From 226e84d782ed635e5e642547fba733bd3a4c87be Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 2 Nov 2023 18:22:58 +0300 Subject: [PATCH] [#684] node: Add skipped objects count to evacuation result Signed-off-by: Dmitrii Stepanov --- pkg/local_object_storage/engine/evacuate.go | 16 ++++++++++++++++ .../engine/evacuate_limiter.go | 7 +++++++ pkg/services/control/server/convert.go | 1 + 3 files changed, 24 insertions(+) diff --git a/pkg/local_object_storage/engine/evacuate.go b/pkg/local_object_storage/engine/evacuate.go index f5f1b658d..7bb37ef61 100644 --- a/pkg/local_object_storage/engine/evacuate.go +++ b/pkg/local_object_storage/engine/evacuate.go @@ -41,6 +41,7 @@ type EvacuateShardRes struct { evacuated *atomic.Uint64 total *atomic.Uint64 failed *atomic.Uint64 + skipped *atomic.Uint64 } // NewEvacuateShardRes creates new EvacuateShardRes instance. @@ -49,6 +50,7 @@ func NewEvacuateShardRes() *EvacuateShardRes { evacuated: new(atomic.Uint64), total: new(atomic.Uint64), failed: new(atomic.Uint64), + skipped: new(atomic.Uint64), } } @@ -97,6 +99,14 @@ func (p *EvacuateShardRes) Failed() uint64 { return p.failed.Load() } +// Skipped returns count of skipped objects. +func (p *EvacuateShardRes) Skipped() uint64 { + if p == nil { + return 0 + } + return p.skipped.Load() +} + // DeepCopy returns deep copy of result instance. func (p *EvacuateShardRes) DeepCopy() *EvacuateShardRes { if p == nil { @@ -107,11 +117,13 @@ func (p *EvacuateShardRes) DeepCopy() *EvacuateShardRes { evacuated: new(atomic.Uint64), total: new(atomic.Uint64), failed: new(atomic.Uint64), + skipped: new(atomic.Uint64), } res.evacuated.Store(p.evacuated.Load()) res.total.Store(p.total.Load()) res.failed.Store(p.failed.Load()) + res.skipped.Store(p.skipped.Load()) return res } @@ -224,6 +236,7 @@ func (e *StorageEngine) evacuateShards(ctx context.Context, shardIDs []string, p zap.Uint64("total", res.Total()), zap.Uint64("evacuated", res.Evacuated()), zap.Uint64("failed", res.Failed()), + zap.Uint64("skipped", res.Skipped()), ) return nil } @@ -404,6 +417,9 @@ func (e *StorageEngine) tryEvacuateObjectLocal(ctx context.Context, addr oid.Add evacuationOperationLogField, zap.String("trace_id", tracingPkg.GetTraceID(ctx))) } + if exists { + res.skipped.Add(1) + } return true, nil } } diff --git a/pkg/local_object_storage/engine/evacuate_limiter.go b/pkg/local_object_storage/engine/evacuate_limiter.go index 62795fa1a..83acd30d9 100644 --- a/pkg/local_object_storage/engine/evacuate_limiter.go +++ b/pkg/local_object_storage/engine/evacuate_limiter.go @@ -55,6 +55,13 @@ func (s *EvacuationState) Failed() uint64 { return s.result.Failed() } +func (s *EvacuationState) Skipped() uint64 { + if s == nil { + return 0 + } + return s.result.Skipped() +} + func (s *EvacuationState) ProcessingStatus() EvacuateProcessState { if s == nil { return EvacuateProcessStateUndefined diff --git a/pkg/services/control/server/convert.go b/pkg/services/control/server/convert.go index 1d29ed406..f922d7278 100644 --- a/pkg/services/control/server/convert.go +++ b/pkg/services/control/server/convert.go @@ -55,6 +55,7 @@ func stateToResponse(state *engine.EvacuationState) (*control.GetShardEvacuation StartedAt: startedAt, Duration: duration, ErrorMessage: state.ErrorMessage(), + Skipped: state.Skipped(), }, }, nil }