Skip to content

Commit 8996162

Browse files
authored
Merge pull request #1858 from devholic/log-get-informer
🌱 Log all errors from cache.GetInformer call
2 parents adc9fa9 + 8aaf7d9 commit 8996162

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/source/source.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"time"
2525

2626
"k8s.io/apimachinery/pkg/api/meta"
27+
"k8s.io/apimachinery/pkg/runtime"
2728
"k8s.io/apimachinery/pkg/util/wait"
2829
"k8s.io/client-go/util/workqueue"
2930
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -133,9 +134,14 @@ func (ks *Kind) Start(ctx context.Context, handler handler.EventHandler, queue w
133134
i, lastErr = ks.cache.GetInformer(ctx, ks.Type)
134135
if lastErr != nil {
135136
kindMatchErr := &meta.NoKindMatchError{}
136-
if errors.As(lastErr, &kindMatchErr) {
137+
switch {
138+
case errors.As(lastErr, &kindMatchErr):
137139
log.Error(lastErr, "if kind is a CRD, it should be installed before calling Start",
138140
"kind", kindMatchErr.GroupKind)
141+
case runtime.IsNotRegisteredError(lastErr):
142+
log.Error(lastErr, "kind must be registered to the Scheme")
143+
default:
144+
log.Error(lastErr, "failed to get informer from cache")
139145
}
140146
return false, nil // Retry.
141147
}

0 commit comments

Comments
 (0)