From 845195b7ed4ac5dcdaaf7469ea136637e2e92b1e Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 4 Oct 2021 08:05:05 +0200 Subject: [PATCH] bandwidth limiting: fix crash with SnapJob zrepl daemon panics when the snap job triggers fixup for f5f269bfd5b1641453989dd0bb9515bbb7b9e202 (bandwidth limiting) fixes #521 Oct 01 16:14:56 cstp zrepl[56563]: panic: invalid config`BandwidthLimit` field invalid: BucketCapacity must not be zero Oct 01 16:14:56 cstp zrepl[56563]: panic: end span: span still has active child spans Oct 01 16:14:56 cstp zrepl[56563]: goroutine 38 [running]: Oct 01 16:14:56 cstp zrepl[56563]: github.com/zrepl/zrepl/daemon/logging/trace.WithSpan.func2() Oct 01 16:14:56 cstp zrepl[56563]: /home/cs/zrepl/zrepl/daemon/logging/trace/trace.go:341 +0x2ea Oct 01 16:14:56 cstp zrepl[56563]: github.com/zrepl/zrepl/daemon/logging/trace.WithTaskAndSpan.func1() Oct 01 16:14:56 cstp zrepl[56563]: /home/cs/zrepl/zrepl/daemon/logging/trace/trace_convenience.go:40 +0x2e Oct 01 16:14:56 cstp zrepl[56563]: panic(0xcee9c0, 0xc000676730) Oct 01 16:14:56 cstp zrepl[56563]: /home/cs/go1.16.6/src/runtime/panic.go:965 +0x1b9 Oct 01 16:14:56 cstp zrepl[56563]: github.com/zrepl/zrepl/endpoint.NewSender(0xf5bbc0, 0xc0003840c0, 0xc0000b2c90, 0x4, 0xc0002c5958, 0x0, 0x0, 0x0, 0xc000068cf8) Oct 01 16:14:56 cstp zrepl[56563]: /home/cs/zrepl/zrepl/endpoint/endpoint.go:68 +0x1ec Oct 01 16:14:56 cstp zrepl[56563]: github.com/zrepl/zrepl/daemon/job.(*SnapJob).doPrune(0xc00039e000, 0xf6e3b8, 0xc0006541b0) Oct 01 16:14:56 cstp zrepl[56563]: /home/cs/zrepl/zrepl/daemon/job/snapjob.go:179 +0x198 Oct 01 16:14:56 cstp zrepl[56563]: github.com/zrepl/zrepl/daemon/job.(*SnapJob).Run(0xc00039e000, 0xf6e3b8, 0xc0001d83c0) Oct 01 16:14:56 cstp zrepl[56563]: /home/cs/zrepl/zrepl/daemon/job/snapjob.go:127 +0x329 Oct 01 16:14:56 cstp zrepl[56563]: github.com/zrepl/zrepl/daemon.(*jobs).start.func1(0xc0006a4100, 0xf6e3b8, 0xc00022a0f0, 0xf72d18, 0xc00039e000) Oct 01 16:14:56 cstp zrepl[56563]: /home/cs/zrepl/zrepl/daemon/daemon.go:255 +0x15b Oct 01 16:14:56 cstp zrepl[56563]: created by github.com/zrepl/zrepl/daemon.(*jobs).start Oct 01 16:14:56 cstp zrepl[56563]: /home/cs/zrepl/zrepl/daemon/daemon.go:251 +0x425 Oct 01 16:14:56 cstp systemd[1]: zrepl.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Oct 01 16:14:56 cstp systemd[1]: zrepl.service: Failed with result 'exit-code'. --- daemon/job/snapjob.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/daemon/job/snapjob.go b/daemon/job/snapjob.go index ea446ba..990ff07 100644 --- a/daemon/job/snapjob.go +++ b/daemon/job/snapjob.go @@ -10,6 +10,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/zrepl/zrepl/daemon/logging/trace" + "github.com/zrepl/zrepl/util/bandwidthlimit" "github.com/zrepl/zrepl/util/nodefault" "github.com/zrepl/zrepl/config" @@ -179,8 +180,11 @@ func (j *SnapJob) doPrune(ctx context.Context) { sender := endpoint.NewSender(endpoint.SenderConfig{ JobID: j.name, FSF: j.fsfilter, - // FIXME encryption setting is irrelevant for SnapJob because the endpoint is only used as pruner.Target - Encrypt: &nodefault.Bool{B: true}, + // FIXME the following config fields are irrelevant for SnapJob + // because the endpoint is only used as pruner.Target. + // However, the implementation requires them to be set. + Encrypt: &nodefault.Bool{B: true}, + BandwidthLimit: bandwidthlimit.NoLimitConfig(), }) j.prunerMtx.Lock() j.pruner = j.prunerFactory.BuildLocalPruner(ctx, sender, alwaysUpToDateReplicationCursorHistory{sender})