From 4037ce9afdea3d09d2a59283d76e075d9a012a3b Mon Sep 17 00:00:00 2001 From: Filip Strozik Date: Wed, 19 Jun 2024 10:02:34 +0200 Subject: [PATCH] add backoff to retry transport layer (#2137) --- internal/registry/portforward/retry.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/registry/portforward/retry.go b/internal/registry/portforward/retry.go index ee28db004..3e6225997 100644 --- a/internal/registry/portforward/retry.go +++ b/internal/registry/portforward/retry.go @@ -6,6 +6,17 @@ import ( "fmt" "io" "net/http" + "time" +) + +var ( + backoffSchedule = []time.Duration{ + time.Millisecond, + time.Millisecond * 10, + time.Millisecond * 100, + time.Millisecond * 1000, + time.Millisecond * 2000, + } ) // onErrorRetryTransport is a RoundTripper that retries requests on error @@ -34,6 +45,7 @@ func (t *onErrorRetryTransport) RoundTrip(req *http.Request) (*http.Response, er } errList = append(errList, err) + time.Sleep(backoffSchedule[i]) } return nil, errors.Join(errList...)