More fine grained error messages for retries (#2545)

## Description

This should help in figuring out more retry failures.

## Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No 

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #<issue>

## Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abin Simon 2023-02-18 22:46:42 +05:30 committed by GitHub
parent 6b79355948
commit 7e3532832e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -6,7 +6,7 @@ import (
"strconv"
"time"
"github.com/alcionai/corso/src/internal/connector/support"
"github.com/alcionai/clues"
backoff "github.com/cenkalti/backoff/v4"
khttp "github.com/microsoft/kiota-http-go"
)
@ -50,7 +50,10 @@ func (middleware RetryHandler) retryRequest(
response, err := pipeline.Next(req, middlewareIndex)
if err != nil && !IsErrTimeout(err) {
return response, support.ConnectorStackErrorTraceWrap(err, "maximum retries or unretryable")
return response, clues.Stack(err).
WithClues(ctx).
With("retry_count", executionCount).
With(ErrData(err)...)
}
return middleware.retryRequest(ctx,
@ -64,7 +67,14 @@ func (middleware RetryHandler) retryRequest(
err)
}
return resp, support.ConnectorStackErrorTraceWrap(respErr, "maximum retries or unretryable")
if respErr != nil {
return nil, clues.Stack(respErr).
WithClues(ctx).
With("retry_count", executionCount).
With(ErrData(respErr)...)
}
return resp, nil
}
func (middleware RetryHandler) isRetriableErrorCode(req *http.Request, code int) bool {

View File

@ -336,7 +336,7 @@ func (middleware RetryHandler) Intercept(
response, err := pipeline.Next(req, middlewareIndex)
if err != nil && !IsErrTimeout(err) {
return nil, clues.Stack(err).WithClues(ctx).With(ErrData(err)...)
return response, clues.Stack(err).WithClues(ctx).With(ErrData(err)...)
}
exponentialBackOff := backoff.NewExponentialBackOff()