[#684] node: Add skipped objects count to evacuation result

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-11-02 18:22:58 +03:00
parent 9b51843aa5
commit 90a90c2820
3 changed files with 24 additions and 0 deletions

View file

@ -41,6 +41,7 @@ type EvacuateShardRes struct {
evacuated *atomic.Uint64 evacuated *atomic.Uint64
total *atomic.Uint64 total *atomic.Uint64
failed *atomic.Uint64 failed *atomic.Uint64
skipped *atomic.Uint64
} }
// NewEvacuateShardRes creates new EvacuateShardRes instance. // NewEvacuateShardRes creates new EvacuateShardRes instance.
@ -49,6 +50,7 @@ func NewEvacuateShardRes() *EvacuateShardRes {
evacuated: new(atomic.Uint64), evacuated: new(atomic.Uint64),
total: new(atomic.Uint64), total: new(atomic.Uint64),
failed: new(atomic.Uint64), failed: new(atomic.Uint64),
skipped: new(atomic.Uint64),
} }
} }
@ -97,6 +99,14 @@ func (p *EvacuateShardRes) Failed() uint64 {
return p.failed.Load() 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. // DeepCopy returns deep copy of result instance.
func (p *EvacuateShardRes) DeepCopy() *EvacuateShardRes { func (p *EvacuateShardRes) DeepCopy() *EvacuateShardRes {
if p == nil { if p == nil {
@ -107,11 +117,13 @@ func (p *EvacuateShardRes) DeepCopy() *EvacuateShardRes {
evacuated: new(atomic.Uint64), evacuated: new(atomic.Uint64),
total: new(atomic.Uint64), total: new(atomic.Uint64),
failed: new(atomic.Uint64), failed: new(atomic.Uint64),
skipped: new(atomic.Uint64),
} }
res.evacuated.Store(p.evacuated.Load()) res.evacuated.Store(p.evacuated.Load())
res.total.Store(p.total.Load()) res.total.Store(p.total.Load())
res.failed.Store(p.failed.Load()) res.failed.Store(p.failed.Load())
res.skipped.Store(p.skipped.Load())
return res return res
} }
@ -224,6 +236,7 @@ func (e *StorageEngine) evacuateShards(ctx context.Context, shardIDs []string, p
zap.Uint64("total", res.Total()), zap.Uint64("total", res.Total()),
zap.Uint64("evacuated", res.Evacuated()), zap.Uint64("evacuated", res.Evacuated()),
zap.Uint64("failed", res.Failed()), zap.Uint64("failed", res.Failed()),
zap.Uint64("skipped", res.Skipped()),
) )
return nil return nil
} }
@ -404,6 +417,9 @@ func (e *StorageEngine) tryEvacuateObjectLocal(ctx context.Context, addr oid.Add
evacuationOperationLogField, evacuationOperationLogField,
zap.String("trace_id", tracingPkg.GetTraceID(ctx))) zap.String("trace_id", tracingPkg.GetTraceID(ctx)))
} }
if exists {
res.skipped.Add(1)
}
return true, nil return true, nil
} }
} }

View file

@ -55,6 +55,13 @@ func (s *EvacuationState) Failed() uint64 {
return s.result.Failed() return s.result.Failed()
} }
func (s *EvacuationState) Skipped() uint64 {
if s == nil {
return 0
}
return s.result.Skipped()
}
func (s *EvacuationState) ProcessingStatus() EvacuateProcessState { func (s *EvacuationState) ProcessingStatus() EvacuateProcessState {
if s == nil { if s == nil {
return EvacuateProcessStateUndefined return EvacuateProcessStateUndefined

View file

@ -55,6 +55,7 @@ func stateToResponse(state *engine.EvacuationState) (*control.GetShardEvacuation
StartedAt: startedAt, StartedAt: startedAt,
Duration: duration, Duration: duration,
ErrorMessage: state.ErrorMessage(), ErrorMessage: state.ErrorMessage(),
Skipped: state.Skipped(),
}, },
}, nil }, nil
} }