client-go: chain the error returned by rate limiter

This commit is contained in:
Abu Kashem 2022-02-24 17:28:01 -05:00
parent a41f9e976d
commit 6acbe7e645
No known key found for this signature in database
GPG Key ID: 33A4FA7088DB68A9
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
} }