This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit 76ae819 authored Nov 10, 2022 Verified
1 parent 353a117 commit 76ae819 Copy full SHA for 76ae819
File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package retry
18
18
19
19
import (
20
20
"context"
21
+ "errors"
21
22
"fmt"
22
23
23
24
"github.com/google/go-containerregistry/internal/retry/wait"
@@ -36,7 +37,7 @@ type temporary interface {
36
37
37
38
// IsTemporary returns true if err implements Temporary() and it returns true.
38
39
func IsTemporary (err error ) bool {
39
- if err == context .DeadlineExceeded {
40
+ if errors . Is ( err , context .DeadlineExceeded ) {
40
41
return false
41
42
}
42
43
if te , ok := err .(temporary ); ok && te .Temporary () {
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ package retry
17
17
import (
18
18
"context"
19
19
"fmt"
20
+ "net/http"
21
+ "net/url"
20
22
"testing"
21
23
)
22
24
@@ -55,6 +57,14 @@ func TestRetry(t *testing.T) {
55
57
predicate : IsTemporary ,
56
58
err : context .DeadlineExceeded ,
57
59
shouldRetry : false ,
60
+ }, {
61
+ predicate : IsTemporary ,
62
+ err : & url.Error {
63
+ Op : http .MethodPost ,
64
+ URL : "http://127.0.0.1:56520/v2/example/blobs/uploads/" ,
65
+ Err : context .DeadlineExceeded ,
66
+ },
67
+ shouldRetry : false ,
58
68
}} {
59
69
// Make sure we retry 5 times if we shouldRetry.
60
70
steps := 5
You can’t perform that action at this time.
0 commit comments