diff --git a/pkg/kube/watcher.go b/pkg/kube/watcher.go index 7ef0fc04..7ed8395e 100644 --- a/pkg/kube/watcher.go +++ b/pkg/kube/watcher.go @@ -33,7 +33,7 @@ func NewEventWatcher(config *rest.Config, namespace string, throttlePeriod int64 labelCache: NewLabelCache(config), annotationCache: NewAnnotationCache(config), fn: fn, - throttlePeriod: time.Second*time.Duration(throttlePeriod), + throttlePeriod: time.Second * time.Duration(throttlePeriod), } informer.AddEventHandler(watcher) @@ -72,7 +72,11 @@ func (e *EventWatcher) onEvent(event *corev1.Event) { labels, err := e.labelCache.GetLabelsWithCache(&event.InvolvedObject) if err != nil { - log.Error().Err(err).Msg("Cannot list labels of the object") + if ev.InvolvedObject.Kind != "CustomResourceDefinition" { + log.Error().Err(err).Msg("Cannot list labels of the object") + } else { + log.Debug().Err(err).Msg("Cannot list labels of the object (CRD)") + } // Ignoring error, but log it anyways } else { ev.InvolvedObject.Labels = labels @@ -81,7 +85,11 @@ func (e *EventWatcher) onEvent(event *corev1.Event) { annotations, err := e.annotationCache.GetAnnotationsWithCache(&event.InvolvedObject) if err != nil { - log.Error().Err(err).Msg("Cannot list annotations of the object") + if ev.InvolvedObject.Kind != "CustomResourceDefinition" { + log.Error().Err(err).Msg("Cannot list annotations of the object") + } else { + log.Debug().Err(err).Msg("Cannot list annotations of the object (CRD)") + } } else { ev.InvolvedObject.Annotations = annotations ev.InvolvedObject.ObjectReference = *event.InvolvedObject.DeepCopy()