client-go: chain the error returned by rate limiter
This commit is contained in:
		| @@ -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 | ||||||
|   | |||||||
| @@ -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 | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Abu Kashem
					Abu Kashem