From eb06447b9beaeab41b94b9064567127c3f91f15d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Thu, 22 Aug 2024 23:12:01 +0200 Subject: [PATCH] Use math/rand/v2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... and increase the jitter precision Signed-off-by: Miloslav Trmač --- docker/body_reader.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/body_reader.go b/docker/body_reader.go index 7d66ef6bc0..29d3b0420e 100644 --- a/docker/body_reader.go +++ b/docker/body_reader.go @@ -6,7 +6,7 @@ import ( "fmt" "io" "math" - "math/rand" + "math/rand/v2" "net/http" "net/url" "strconv" @@ -158,7 +158,7 @@ func (br *bodyReader) Read(p []byte) (int, error) { logrus.Debugf("Error closing blob body: %v", err) // … and ignore err otherwise } br.body = nil - time.Sleep(1*time.Second + time.Duration(rand.Intn(100_000))*time.Microsecond) // Some jitter so that a failure blip doesn’t cause a deterministic stampede + time.Sleep(1*time.Second + rand.N(100_000*time.Microsecond)) // Some jitter so that a failure blip doesn’t cause a deterministic stampede headers := map[string][]string{ "Range": {fmt.Sprintf("bytes=%d-", br.offset)},