[#684] node: Add skipped objects count to evacuation result
Build / Build Components (1.21) (pull_request) Successful in 2m47s Details
Build / Build Components (1.20) (pull_request) Successful in 3m15s Details
DCO action / DCO (pull_request) Successful in 4m26s Details
Vulncheck / Vulncheck (pull_request) Successful in 5m1s Details
Tests and linters / Lint (pull_request) Successful in 5m20s Details
Tests and linters / Staticcheck (pull_request) Successful in 5m53s Details
Tests and linters / Tests (1.20) (pull_request) Successful in 6m11s Details
Tests and linters / Tests (1.21) (pull_request) Successful in 7m44s Details
Tests and linters / Tests with -race (pull_request) Successful in 8m23s Details

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
pull/785/head
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
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
}
}

View File

@ -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

View File

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