From a45aaad3c9c155d65cce4cd0764be64a7fce76e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Mon, 7 Oct 2024 10:46:36 +0200 Subject: [PATCH] fix(restore): init metrics just once Commit 14aef7be introduced metrics initialization during workload indexing (tablesWorker.initMetrics). It forgot to remove previous metrics initialization (tablesWorker.initRestoreMetrics) performed at the beginning of the restore task. --- pkg/service/restore/tables_worker.go | 55 ---------------------------- 1 file changed, 55 deletions(-) diff --git a/pkg/service/restore/tables_worker.go b/pkg/service/restore/tables_worker.go index 16a2c7305..e79d8b70d 100644 --- a/pkg/service/restore/tables_worker.go +++ b/pkg/service/restore/tables_worker.go @@ -10,8 +10,6 @@ import ( "github.com/pkg/errors" "github.com/scylladb/go-set/strset" - "github.com/scylladb/scylla-manager/v3/pkg/metrics" - . "github.com/scylladb/scylla-manager/v3/pkg/service/backup/backupspec" "github.com/scylladb/scylla-manager/v3/pkg/service/repair" "github.com/scylladb/scylla-manager/v3/pkg/util/parallel" "github.com/scylladb/scylla-manager/v3/pkg/util/query" @@ -90,11 +88,6 @@ func newTablesWorker(w worker, repairSvc *repair.Service, totalBytes int64) (*ta // restore files from every location specified in restore target. func (w *tablesWorker) restore(ctx context.Context) error { - // Init metrics only on fresh start - if w.run.PrevID == uuid.Nil { - w.initRestoreMetrics(ctx) - } - stageFunc := map[Stage]func() error{ StageDropViews: func() error { for _, v := range w.run.Views { @@ -265,51 +258,3 @@ func (w *tablesWorker) stageRepair(ctx context.Context) error { return w.repairSvc.Repair(ctx, w.run.ClusterID, w.run.RepairTaskID, repairRunID, repairTarget) } - -func (w *tablesWorker) initRestoreMetrics(ctx context.Context) { - for _, location := range w.target.Location { - err := w.forEachManifest( - ctx, - location, - func(miwc ManifestInfoWithContent) error { - sizePerTableAndKeyspace := make(map[string]map[string]int64) - err := miwc.ForEachIndexIterWithError( - nil, - func(fm FilesMeta) error { - if !unitsContainTable(w.run.Units, fm.Keyspace, fm.Table) { - return nil - } - - if sizePerTableAndKeyspace[fm.Keyspace] == nil { - sizePerTableAndKeyspace[fm.Keyspace] = make(map[string]int64) - } - sizePerTableAndKeyspace[fm.Keyspace][fm.Table] += fm.Size - return nil - }) - for kspace, sizePerTable := range sizePerTableAndKeyspace { - for table, size := range sizePerTable { - labels := metrics.RestoreBytesLabels{ - ClusterID: w.run.ClusterID.String(), - SnapshotTag: w.target.SnapshotTag, - Location: location.String(), - DC: miwc.DC, - Node: miwc.NodeID, - Keyspace: kspace, - Table: table, - } - w.metrics.SetRemainingBytes(labels, size) - } - } - return err - }) - progressLabels := metrics.RestoreProgressLabels{ - ClusterID: w.run.ClusterID.String(), - SnapshotTag: w.target.SnapshotTag, - } - w.metrics.SetProgress(progressLabels, 0) - if err != nil { - w.logger.Info(ctx, "Couldn't count restore data size") - continue - } - } -}