@@ -20,7 +20,80 @@ const (
20
20
// ConfigKind is the configuration field name for controlling
21
21
// what the layer name in the bundle image is.
22
22
ConfigKind = "default-kind"
23
- // DefaultTimeoutKey is the configuration field name for controlling
23
+ // ConfigTimeoutKey is the configuration field name for controlling
24
24
// the maximum duration of a resolution request for a file from registry.
25
25
ConfigTimeoutKey = "fetch-timeout"
26
+ // ConfigBackoffDuration is the configuration field name for controlling
27
+ // the initial duration of a backoff when a bundle resolution fails
28
+ ConfigBackoffDuration = "backoff-duration"
29
+ DefaultBackoffDuration = 1.0 * time .Second
30
+ // ConfigBackoffFactor is the configuration field name for controlling
31
+ // the factor by which successive backoffs will increase when a bundle
32
+ // resolution fails
33
+ ConfigBackoffFactor = "backoff-factor"
34
+ DefaultBackoffFactor = 3.0
35
+ // ConfigBackoffJitter is the configuration field name for controlling
36
+ // the randomness applied to backoff durations when a bundle resolution fails
37
+ ConfigBackoffJitter = "backoff-jitter"
38
+ DefaultBackoffJitter = 0.1
39
+ // ConfigBackoffSteps is the configuration field name for controlling
40
+ // the number of attempted backoffs to retry when a bundle resolution fails
41
+ ConfigBackoffSteps = "backoff-steps"
42
+ DefaultBackoffSteps = 3
26
43
)
44
+
45
+ type BundleResolverBackoffConfig struct {
46
+ Duration : time.Duration
47
+ Factor : float64
48
+ Jitter : float64
49
+ Steps : int
50
+
51
+ }
52
+
53
+ func {
54
+ conf := framework .GetResolverConfigFromContext (ctx )
55
+ }
56
+
57
+ // GetResolutionTimeout returns a time.Duration for the amount of time a
58
+ // single bundle fetch may take. This can be configured with the
59
+ // fetch-timeout field in the bundle-resolver-config ConfigMap.
60
+ func GetBundleResolverBackoff (ctx context.Context ) (BundleResolverBackoffConfig , error ) {
61
+ conf := framework .GetResolverConfigFromContext (ctx )
62
+
63
+ customRetryBackoff := BundleResolverBackoffConfig {
64
+ Duration : DefaultBackoffDuration ,
65
+ Factor : DefaultBackoffFactor ,
66
+ Jitter : DefaultBackoffJitter ,
67
+ Steps : DefaultBackoffSteps ,
68
+ }
69
+ if v , ok := conf [ConfigBackoffDuration ]; ok {
70
+ var err error
71
+ duration , err = time .ParseDuration (v )
72
+ if err != nil {
73
+ return customRetryBackoff , fmt .Errorf ("error parsing backoff duration value %s: %w" , v , err )
74
+ }
75
+ }
76
+ if v , ok := conf [ConfigBackoffFactor ]; ok {
77
+ var err error
78
+ factor , err = strconv.ParseFloat (string (v , 64 )
79
+ if err != nil {
80
+ return customRetryBackoff , fmt .Errorf ("error parsing backoff factor value %s: %w" , v , err )
81
+ }
82
+ }
83
+ if v , ok := conf [ConfigBackoffJitter ]; ok {
84
+ var err error
85
+ factor , err = strconv.ParseFloat (string (v , 64 )
86
+ if err != nil {
87
+ return customRetryBackoff , fmt .Errorf ("error parsing backoff jitter value %s: %w" , v , err )
88
+ }
89
+ }
90
+ if v , ok := conf [ConfigBackoffSteps ]; ok {
91
+ var err error
92
+ factor , err = strconv.ParseInt (string (v )
93
+ if err != nil {
94
+ return customRetryBackoff , fmt .Errorf ("error parsing backoff steps value %s: %w" , v , err )
95
+ }
96
+ }
97
+
98
+ return customRetryBackoff , nil
99
+ }
0 commit comments