@@ -20,17 +20,21 @@ import (
20
20
"fmt"
21
21
"sync"
22
22
23
+ "k8s.io/apimachinery/pkg/api/meta"
23
24
"k8s.io/apimachinery/pkg/runtime"
24
25
"k8s.io/client-go/util/workqueue"
25
26
"sigs.k8s.io/controller-runtime/pkg/event"
26
27
"sigs.k8s.io/controller-runtime/pkg/handler"
27
28
"sigs.k8s.io/controller-runtime/pkg/runtime/inject"
29
+ logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
28
30
"sigs.k8s.io/controller-runtime/pkg/source/internal"
29
31
30
32
"sigs.k8s.io/controller-runtime/pkg/cache"
31
33
"sigs.k8s.io/controller-runtime/pkg/predicate"
32
34
)
33
35
36
+ var log = logf .KBLog .WithName ("source" )
37
+
34
38
const (
35
39
// defaultBufferSize is the default number of event notifications that can be buffered.
36
40
defaultBufferSize = 1024
@@ -80,6 +84,10 @@ func (ks *Kind) Start(handler handler.EventHandler, queue workqueue.RateLimiting
80
84
// Lookup the Informer from the Cache and add an EventHandler which populates the Queue
81
85
i , err := ks .cache .GetInformer (ks .Type )
82
86
if err != nil {
87
+ if kindMatchErr , ok := err .(* meta.NoKindMatchError ); ok {
88
+ log .Error (err , "if %s is a CRD, should install it before calling Start" ,
89
+ kindMatchErr .GroupKind )
90
+ }
83
91
return err
84
92
}
85
93
i .AddEventHandler (internal.EventHandler {Queue : queue , EventHandler : handler , Predicates : prct })
0 commit comments