[arvados] updated: 2.6.0-208-gf4a37bb12

git repository hosting git at public.arvados.org
Wed May 31 19:25:23 UTC 2023


Summary of changes:
 sdk/go/arvados/client.go      | 5 +++++
 sdk/go/arvados/client_test.go | 5 +++++
 2 files changed, 10 insertions(+)

       via  f4a37bb12147851402fd585e6e5987f227591028 (commit)
      from  54e9c47a8340c5952e8e4c0e96e33eb47c3cb963 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit f4a37bb12147851402fd585e6e5987f227591028
Author: Tom Clegg <tom at curii.com>
Date:   Wed May 31 15:24:30 2023 -0400

    20540: Ensure delay>0 at attempt>0, even if requested min=0.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/arvados/client.go b/sdk/go/arvados/client.go
index c40314650..636592b5a 100644
--- a/sdk/go/arvados/client.go
+++ b/sdk/go/arvados/client.go
@@ -374,12 +374,17 @@ func isRedirectStatus(code int) bool {
 	}
 }
 
+const minExponentialBackoffBase = time.Second
+
 // Implements retryablehttp.Backoff using the server-provided
 // Retry-After header if available, otherwise nearly-full jitter
 // exponential backoff (similar to
 // https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/),
 // in all cases respecting the provided min and max.
 func exponentialBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {
+	if attemptNum > 0 && min < minExponentialBackoffBase {
+		min = minExponentialBackoffBase
+	}
 	var t time.Duration
 	if resp != nil && (resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode == http.StatusServiceUnavailable) {
 		if s := resp.Header.Get("Retry-After"); s != "" {
diff --git a/sdk/go/arvados/client_test.go b/sdk/go/arvados/client_test.go
index b1aae00da..b7c60fbf8 100644
--- a/sdk/go/arvados/client_test.go
+++ b/sdk/go/arvados/client_test.go
@@ -397,4 +397,9 @@ func (s *clientRetrySuite) TestExponentialBackoff(c *check.C) {
 		StatusCode: http.StatusTooManyRequests,
 	})
 	c.Check(t, check.Equals, time.Second*4)
+
+	t = exponentialBackoff(0, max, 0, nil)
+	c.Check(t, check.Equals, time.Duration(0))
+	t = exponentialBackoff(0, max, 1, nil)
+	c.Check(t, check.Not(check.Equals), time.Duration(0))
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list