Merge pull request #108342 from tkashem/rate-limit-error

client-go: chain the error returned by rate limiter
This commit is contained in:
Kubernetes Prow Robot
2022-03-23 13:21:43 -07:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -504,7 +504,9 @@ func (r *Request) tryThrottleWithInfo(ctx context.Context, retryInfo string) err
now := time.Now() now := time.Now()
err := r.rateLimiter.Wait(ctx) err := r.rateLimiter.Wait(ctx)
if err != nil {
err = fmt.Errorf("client rate limiter Wait returned an error: %w", err)
}
latency := time.Since(now) latency := time.Since(now)
var message string var message string

View File

@@ -23,6 +23,7 @@ import (
"crypto/x509" "crypto/x509"
"crypto/x509/pkix" "crypto/x509/pkix"
"encoding/pem" "encoding/pem"
"errors"
"math" "math"
"math/big" "math/big"
"os" "os"
@@ -135,7 +136,9 @@ func TestCertRotationContinuousRequests(t *testing.T) {
for range time.Tick(time.Second) { for range time.Tick(time.Second) {
_, err := client.CoreV1().ServiceAccounts("default").List(ctx, v1.ListOptions{}) _, err := client.CoreV1().ServiceAccounts("default").List(ctx, v1.ListOptions{})
if err != nil { if err != nil {
if err == ctx.Err() { // client may wrap the context.Canceled error, so we can't
// do 'err == ctx.Err()', instead use 'errors.Is'.
if errors.Is(err, context.Canceled) {
return return
} }