From 68639b4bf9d679f0ebc180828a1110234913fd03 Mon Sep 17 00:00:00 2001 From: Diaa Sami Date: Fri, 25 Mar 2022 11:09:33 +0100 Subject: [PATCH] koji: increment retry counter only when retrying --- internal/upload/koji/koji.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/upload/koji/koji.go b/internal/upload/koji/koji.go index db2c340c8..5a43f8ea2 100644 --- a/internal/upload/koji/koji.go +++ b/internal/upload/koji/koji.go @@ -314,7 +314,6 @@ func (k *Koji) uploadChunk(chunk []byte, filepath, filename string, offset uint6 retries := uint(0) countingCheckRetry := func(ctx context.Context, resp *http.Response, err error) (bool, error) { - retries++ shouldRetry, retErr := rh.DefaultRetryPolicy(ctx, resp, err) // DefaultRetryPolicy denies retrying for any certificate related error. @@ -323,11 +322,16 @@ func (k *Koji) uploadChunk(chunk []byte, filepath, filename string, offset uint6 if v, ok := err.(*url.Error); ok { if _, ok := v.Err.(x509.UnknownAuthorityError); ok { // retry if it's a timeout - return strings.Contains(strings.ToLower(v.Error()), "timeout"), v + shouldRetry = strings.Contains(strings.ToLower(v.Error()), "timeout") + retErr = v } } } + if shouldRetry { + retries++ + } + return shouldRetry, retErr }