Skip to content

Commit

Permalink
Log 'not found' error instead of returning it alongside RequeueAfter
Browse files Browse the repository at this point in the history
(cherry picked from commit 3824fa1)
  • Loading branch information
abays authored and stuggi committed Sep 4, 2024
1 parent 32cc1b1 commit eec764b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion modules/common/configmap/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/log"

corev1 "k8s.io/api/core/v1"
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -283,9 +284,10 @@ func VerifyConfigMap(
err := reader.Get(ctx, configMapName, configMap)
if err != nil {
if k8s_errors.IsNotFound(err) {
log.FromContext(ctx).Info("ConfigMap not found", "configMapName", configMapName)
return "",
ctrl.Result{RequeueAfter: requeueTimeout},
fmt.Errorf("ConfigMap %s not found", configMapName)
nil
}
return "", ctrl.Result{}, fmt.Errorf("Get ConfigMap %s failed: %w", configMapName, err)
}
Expand Down
4 changes: 3 additions & 1 deletion modules/common/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/log"
)

// Hash function creates a hash of a Secret's Data and StringData fields and
Expand Down Expand Up @@ -420,9 +421,10 @@ func VerifySecret(
err := reader.Get(ctx, secretName, secret)
if err != nil {
if k8s_errors.IsNotFound(err) {
log.FromContext(ctx).Info("Secret not found", "secretName", secretName)
return "",
ctrl.Result{RequeueAfter: requeueTimeout},
fmt.Errorf("Secret %s not found", secretName)
nil
}
return "", ctrl.Result{}, fmt.Errorf("Get secret %s failed: %w", secretName, err)
}
Expand Down

0 comments on commit eec764b

Please sign in to comment.