Skip to content

Commit

Permalink
refactor(backup): remove unnecessary calls to RcloneSetBandwidthLimit
Browse files Browse the repository at this point in the history
Setting bandwidth limit should be handled by specific Rclone calls.
  • Loading branch information
Michal-Leszczynski committed Nov 22, 2024
1 parent c35f364 commit 9efd51e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
5 changes: 5 additions & 0 deletions pkg/scyllaclient/client_rclone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 0 additions & 4 deletions pkg/service/backup/worker_deduplicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 0 additions & 9 deletions pkg/service/backup/worker_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9efd51e

Please sign in to comment.