Skip to content

Commit

Permalink
Merge pull request #547 from abays/fix_requeues
Browse files Browse the repository at this point in the history
Log 'not found' error instead of returning it alongside RequeueAfter
  • Loading branch information
stuggi authored Aug 6, 2024
2 parents 1c08e6b + 3824fa1 commit 80a1935
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 80a1935

Please sign in to comment.