From 9efd51e5d0da5962117287f720d791958a6f85c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Fri, 22 Nov 2024 12:16:13 +0100 Subject: [PATCH] refactor(backup): remove unnecessary calls to RcloneSetBandwidthLimit Setting bandwidth limit should be handled by specific Rclone calls. --- pkg/scyllaclient/client_rclone.go | 5 +++++ pkg/service/backup/worker_deduplicate.go | 4 ---- pkg/service/backup/worker_upload.go | 9 --------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/pkg/scyllaclient/client_rclone.go b/pkg/scyllaclient/client_rclone.go index 8b8ae6854..c8750ff84 100644 --- a/pkg/scyllaclient/client_rclone.go +++ b/pkg/scyllaclient/client_rclone.go @@ -24,6 +24,11 @@ import ( // transfers performed under current client session. // Limit is expressed in MiB per second. // To turn off limitation set it to 0. +// +// Note that it's safer to set bandwidth limit as a parameter of given Rclone call +// (e.g. RcloneMoveDir or RcloneCopyPaths) as it's resistant to agent restarts +// or some other process modifying Rclone bandwidth limit in the meantime. +// Because of that, this method should be used in tests only. func (c *Client) RcloneSetBandwidthLimit(ctx context.Context, host string, limit int) error { p := operations.CoreBwlimitParams{ Context: forceHost(ctx, host), diff --git a/pkg/service/backup/worker_deduplicate.go b/pkg/service/backup/worker_deduplicate.go index 82cdf59ec..e3b5fdc2a 100644 --- a/pkg/service/backup/worker_deduplicate.go +++ b/pkg/service/backup/worker_deduplicate.go @@ -56,10 +56,6 @@ func (w *worker) deduplicateHost(ctx context.Context, h hostInfo) error { }(w.hostSnapshotDirs(h)) } - if err := w.setRateLimit(ctx, h); err != nil { - return errors.Wrap(err, "set rate limit") - } - dirs := w.hostSnapshotDirs(h) f := func(i int) (err error) { d := &dirs[i] diff --git a/pkg/service/backup/worker_upload.go b/pkg/service/backup/worker_upload.go index d57a57c07..23a76955f 100644 --- a/pkg/service/backup/worker_upload.go +++ b/pkg/service/backup/worker_upload.go @@ -32,10 +32,6 @@ func (w *worker) Upload(ctx context.Context, hosts []hostInfo, limits []DCLimit) } func (w *worker) uploadHost(ctx context.Context, h hostInfo) error { - if err := w.setRateLimit(ctx, h); err != nil { - return errors.Wrap(err, "set rate limit") - } - dirs := w.hostSnapshotDirs(h) f := func(i int) (err error) { @@ -151,11 +147,6 @@ func (w *worker) snapshotJobID(ctx context.Context, d snapshotDir) int64 { return 0 } -func (w *worker) setRateLimit(ctx context.Context, h hostInfo) error { - w.Logger.Info(ctx, "Setting rate limit", "host", h.IP, "limit", h.RateLimit.Limit) - return w.Client.RcloneSetBandwidthLimit(ctx, h.IP, h.RateLimit.Limit) -} - func (w *worker) uploadSnapshotDir(ctx context.Context, h hostInfo, d snapshotDir) error { w.Logger.Info(ctx, "Uploading table snapshot", "host", h.IP,