retry dpop - #1118
Conversation
| } | ||
|
|
||
| func (c *tokenSource) Token() (*oauth2.Token, error) { | ||
| ctx, done := context.WithTimeout(c.baseCtx, time.Second*30) |
There was a problem hiding this comment.
🟡 Suggestion: The retry loop shares one 30s budget with each attempt's HTTP request, and pkg/lambda/grpc/config/config.go:149 sets lambdaHTTPClientTimeout = 30 * time.Second on the client passed via WithHTTPClient. So for the hung/timed-out token POST — the exact class tryToken now marks transient — the first attempt consumes the whole budget, sleepBeforeRetry returns false immediately, and zero retries happen. Retries only help for fast 5xx/429. Consider lowering the lambda per-request timeout (e.g. ~8-10s) or passing WithRetryConfig so a retry cycle actually fits.
| // isRetryableStatus reports whether an HTTP response status is worth | ||
| // retrying: any 5xx (upstream failure) or 429 (throttling). 4xx OAuth | ||
| // protocol rejections are definitive and must not be retried. | ||
| func isRetryableStatus(code int) bool { |
There was a problem hiding this comment.
🟡 Suggestion: 429 is classified retryable but the backoff ignores the Retry-After response header, so a throttled client retries after ~0.5s/1s regardless of what the authorization server asked for — which can extend the throttle. Consider plumbing resp.Header.Get("Retry-After") from tryToken into the delay computation (clamped to the remaining Token() budget), or excluding 429 from the retryable set until that's honored.
| token, err := d.tokenSource.Token() | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, tokenStatusError(err) |
There was a problem hiding this comment.
🟡 Suggestion: GetRequestMetadata still calls d.tokenSource.Token() without the RPC ctx, and Token() uses its own baseCtx (context.Background() in pkg/lambda/grpc/config/config.go). With retries now enabled by default, a per-RPC creds call can block through the full backoff cycle instead of failing fast, and because the SDK wraps this in oauth2.ReuseTokenSource (config.go:100) every concurrent RPC serializes behind that one retrying call. Worth confirming this latency change is acceptable for RPCs with short deadlines.
General PR Review: retry dpopBlocking Issues: 0 | Suggestions: 4 | Threads Resolved: 0 Review SummaryScanned the full PR diff for security and correctness: it bumps Risk triage (per Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agents |
No description provided.