forked from TrueCloudLab/frostfs-node
[#661] metrcis: Add rebuild percent metric
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
8bbfb2df43
commit
8911656b1a
4 changed files with 30 additions and 0 deletions
|
@ -23,6 +23,7 @@ type Metrics interface {
|
|||
|
||||
SetRebuildStatus(status string)
|
||||
ObjectMoved(d time.Duration)
|
||||
SetRebuildPercent(value uint32)
|
||||
|
||||
Delete(d time.Duration, success, withStorageID bool)
|
||||
Exists(d time.Duration, success, withStorageID bool)
|
||||
|
@ -38,6 +39,7 @@ func (m *noopMetrics) SetParentID(string) {}
|
|||
func (m *noopMetrics) SetMode(bool) {}
|
||||
func (m *noopMetrics) Close() {}
|
||||
func (m *noopMetrics) SetRebuildStatus(string) {}
|
||||
func (m *noopMetrics) SetRebuildPercent(uint32) {}
|
||||
func (m *noopMetrics) ObjectMoved(time.Duration) {}
|
||||
func (m *noopMetrics) Delete(time.Duration, bool, bool) {}
|
||||
func (m *noopMetrics) Exists(time.Duration, bool, bool) {}
|
||||
|
|
|
@ -30,6 +30,7 @@ func (b *Blobovniczas) Rebuild(ctx context.Context, prm common.RebuildPrm) (comm
|
|||
}
|
||||
|
||||
b.metrics.SetRebuildStatus(rebuildStatusRunning)
|
||||
b.metrics.SetRebuildPercent(0)
|
||||
success := true
|
||||
defer func() {
|
||||
if success {
|
||||
|
@ -71,6 +72,7 @@ func (b *Blobovniczas) Rebuild(ctx context.Context, prm common.RebuildPrm) (comm
|
|||
}
|
||||
|
||||
func (b *Blobovniczas) migrateDBs(ctx context.Context, dbs []string, prm common.RebuildPrm, res common.RebuildRes) (common.RebuildRes, error) {
|
||||
var completedDBCount uint32
|
||||
for _, db := range dbs {
|
||||
b.log.Debug(logs.BlobovniczaTreeRebuildingBlobovnicza, zap.String("path", db))
|
||||
movedObjects, err := b.rebuildDB(ctx, db, prm.MetaStorage, prm.WorkerLimiter)
|
||||
|
@ -81,7 +83,10 @@ func (b *Blobovniczas) migrateDBs(ctx context.Context, dbs []string, prm common.
|
|||
}
|
||||
b.log.Debug(logs.BlobovniczaTreeRebuildingBlobovniczaSuccess, zap.String("path", db), zap.Uint64("moved_objects_count", movedObjects))
|
||||
res.FilesRemoved++
|
||||
completedDBCount++
|
||||
b.metrics.SetRebuildPercent((100 * completedDBCount) / uint32(len(dbs)))
|
||||
}
|
||||
b.metrics.SetRebuildPercent(100)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue