@@ -11,6 +11,7 @@ import (
1111 "fmt"
1212 "reflect"
1313 "strings"
14+ "time"
1415
1516 corev1 "k8s.io/api/core/v1"
1617 apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -30,6 +31,8 @@ const (
3031 tagFallbackKeys = "fallbackKeys"
3132
3233 notFoundPolicyIgnoreOnDeletion = "ignoreOnDeletion"
34+
35+ retryAfter = 10 * time .Second
3336)
3437
3538// +kubebuilder:object:generate=true
@@ -50,7 +53,7 @@ func (r *ConfigMapReference) load(ctx context.Context, clnt client.Client, names
5053 if ignoreNotFound {
5154 return nil
5255 }
53- return types .NewRetriableError (errors .Wrapf (err , "error loading configmap %s/%s" , namespace , r .Name ), nil )
56+ return types .NewRetriableError (errors .Wrapf (err , "error loading configmap %s/%s" , namespace , r .Name ), ref ( retryAfter ) )
5457 } else {
5558 return errors .Wrapf (err , "error loading configmap %s/%s" , namespace , r .Name )
5659 }
@@ -102,7 +105,7 @@ func (r *ConfigMapKeyReference) load(ctx context.Context, clnt client.Client, na
102105 if ignoreNotFound {
103106 return nil
104107 }
105- return types .NewRetriableError (errors .Wrapf (err , "error loading configmap %s/%s" , namespace , r .Name ), nil )
108+ return types .NewRetriableError (errors .Wrapf (err , "error loading configmap %s/%s" , namespace , r .Name ), ref ( retryAfter ) )
106109 } else {
107110 return errors .Wrapf (err , "error loading configmap %s/%s" , namespace , r .Name )
108111 }
@@ -113,7 +116,7 @@ func (r *ConfigMapKeyReference) load(ctx context.Context, clnt client.Client, na
113116 r .loaded = true
114117 return nil
115118 } else {
116- return types .NewRetriableError (fmt .Errorf ("key %s not found in configmap %s/%s" , r .Key , namespace , r .Name ), nil )
119+ return types .NewRetriableError (fmt .Errorf ("key %s not found in configmap %s/%s" , r .Key , namespace , r .Name ), ref ( retryAfter ) )
117120 }
118121 } else {
119122 for _ , key := range fallbackKeys {
@@ -123,7 +126,7 @@ func (r *ConfigMapKeyReference) load(ctx context.Context, clnt client.Client, na
123126 return nil
124127 }
125128 }
126- return types .NewRetriableError (fmt .Errorf ("no matching key found in configmap %s/%s" , namespace , r .Name ), nil )
129+ return types .NewRetriableError (fmt .Errorf ("no matching key found in configmap %s/%s" , namespace , r .Name ), ref ( retryAfter ) )
127130 }
128131}
129132
@@ -161,7 +164,7 @@ func (r *SecretReference) load(ctx context.Context, clnt client.Client, namespac
161164 if ignoreNotFound {
162165 return nil
163166 }
164- return types .NewRetriableError (errors .Wrapf (err , "error loading secret %s/%s" , namespace , r .Name ), nil )
167+ return types .NewRetriableError (errors .Wrapf (err , "error loading secret %s/%s" , namespace , r .Name ), ref ( retryAfter ) )
165168 } else {
166169 return errors .Wrapf (err , "error loading secret %s/%s" , namespace , r .Name )
167170 }
@@ -213,7 +216,7 @@ func (r *SecretKeyReference) load(ctx context.Context, clnt client.Client, names
213216 if ignoreNotFound {
214217 return nil
215218 }
216- return types .NewRetriableError (errors .Wrapf (err , "error loading secret %s/%s" , namespace , r .Name ), nil )
219+ return types .NewRetriableError (errors .Wrapf (err , "error loading secret %s/%s" , namespace , r .Name ), ref ( retryAfter ) )
217220 } else {
218221 return errors .Wrapf (err , "error loading secret %s/%s" , namespace , r .Name )
219222 }
@@ -224,7 +227,7 @@ func (r *SecretKeyReference) load(ctx context.Context, clnt client.Client, names
224227 r .loaded = true
225228 return nil
226229 } else {
227- return types .NewRetriableError (fmt .Errorf ("key %s not found in secret %s/%s" , r .Key , namespace , r .Name ), nil )
230+ return types .NewRetriableError (fmt .Errorf ("key %s not found in secret %s/%s" , r .Key , namespace , r .Name ), ref ( retryAfter ) )
228231 }
229232 } else {
230233 for _ , key := range fallbackKeys {
@@ -234,7 +237,7 @@ func (r *SecretKeyReference) load(ctx context.Context, clnt client.Client, names
234237 return nil
235238 }
236239 }
237- return types .NewRetriableError (fmt .Errorf ("no matching key found in secret %s/%s" , namespace , r .Name ), nil )
240+ return types .NewRetriableError (fmt .Errorf ("no matching key found in secret %s/%s" , namespace , r .Name ), ref ( retryAfter ) )
238241 }
239242}
240243
0 commit comments