Skip to content

Commit

Permalink
add backoff to retry transport layer (#2137)
Browse files Browse the repository at this point in the history
  • Loading branch information
pPrecel authored Jun 19, 2024
1 parent 8e3dc77 commit 4037ce9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/registry/portforward/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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...)
Expand Down

0 comments on commit 4037ce9

Please sign in to comment.