Skip to content

Commit 80a1935

Browse files
authored
Merge pull request #547 from abays/fix_requeues
Log 'not found' error instead of returning it alongside RequeueAfter
2 parents 1c08e6b + 3824fa1 commit 80a1935

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

modules/common/configmap/configmap.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
ctrl "sigs.k8s.io/controller-runtime"
3030
"sigs.k8s.io/controller-runtime/pkg/client"
3131
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
32+
"sigs.k8s.io/controller-runtime/pkg/log"
3233

3334
corev1 "k8s.io/api/core/v1"
3435
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
@@ -283,9 +284,10 @@ func VerifyConfigMap(
283284
err := reader.Get(ctx, configMapName, configMap)
284285
if err != nil {
285286
if k8s_errors.IsNotFound(err) {
287+
log.FromContext(ctx).Info("ConfigMap not found", "configMapName", configMapName)
286288
return "",
287289
ctrl.Result{RequeueAfter: requeueTimeout},
288-
fmt.Errorf("ConfigMap %s not found", configMapName)
290+
nil
289291
}
290292
return "", ctrl.Result{}, fmt.Errorf("Get ConfigMap %s failed: %w", configMapName, err)
291293
}

modules/common/secret/secret.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
ctrl "sigs.k8s.io/controller-runtime"
3535
"sigs.k8s.io/controller-runtime/pkg/client"
3636
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
37+
"sigs.k8s.io/controller-runtime/pkg/log"
3738
)
3839

3940
// Hash function creates a hash of a Secret's Data and StringData fields and
@@ -420,9 +421,10 @@ func VerifySecret(
420421
err := reader.Get(ctx, secretName, secret)
421422
if err != nil {
422423
if k8s_errors.IsNotFound(err) {
424+
log.FromContext(ctx).Info("Secret not found", "secretName", secretName)
423425
return "",
424426
ctrl.Result{RequeueAfter: requeueTimeout},
425-
fmt.Errorf("Secret %s not found", secretName)
427+
nil
426428
}
427429
return "", ctrl.Result{}, fmt.Errorf("Get secret %s failed: %w", secretName, err)
428430
}

0 commit comments

Comments
 (0)